@worknice/whiteboard 0.12.11 → 0.14.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.
- package/dist/controls/MenuButton.d.ts +12 -2
- package/dist/controls/MenuButton.js +139 -91
- package/dist/controls/MenuButton.module.js +2 -0
- package/dist/controls/MenuButton_module.css +9 -0
- package/dist/fields/SingleSelectComboboxField.d.ts +12 -4
- package/dist/fields/SingleSelectComboboxField.js +46 -8
- package/dist/inputs/SingleSelectComboboxInput.d.ts +11 -3
- package/dist/inputs/SingleSelectComboboxInput.js +137 -81
- package/dist/inputs/SingleSelectComboboxInput.module.js +1 -0
- package/dist/inputs/SingleSelectComboboxInput_module.css +5 -0
- package/dist/presentation/Tooltip.js +3 -3
- package/dist/validators/isValidDate.d.ts +8 -0
- package/dist/validators/isValidDate.js +18 -0
- package/package.json +2 -2
|
@@ -16,16 +16,26 @@ type Props = {
|
|
|
16
16
|
autoFocus?: boolean;
|
|
17
17
|
disabled?: boolean;
|
|
18
18
|
id?: string;
|
|
19
|
-
options: Array<Option | null>;
|
|
20
19
|
searchPlaceholder?: string;
|
|
21
20
|
displaySearch?: boolean;
|
|
22
21
|
iconRight?: ReactNode;
|
|
22
|
+
fullWidth?: boolean;
|
|
23
23
|
} & ({
|
|
24
24
|
children: ReactNode;
|
|
25
25
|
icon?: ReactNode;
|
|
26
26
|
} | {
|
|
27
27
|
children?: ReactNode;
|
|
28
28
|
icon: ReactNode;
|
|
29
|
+
}) & ({
|
|
30
|
+
options: Array<Option | null>;
|
|
31
|
+
optionGroups?: never;
|
|
32
|
+
} | {
|
|
33
|
+
options?: never;
|
|
34
|
+
optionGroups: Array<{
|
|
35
|
+
header: string;
|
|
36
|
+
options: Array<Option | null>;
|
|
37
|
+
}>;
|
|
29
38
|
});
|
|
30
|
-
declare const MenuButton: ({ autoFocus, disabled, id, options, searchPlaceholder, children, icon, iconRight, displaySearch, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
declare const MenuButton: ({ autoFocus, disabled, id, options, optionGroups, searchPlaceholder, children, icon, iconRight, displaySearch, fullWidth, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
31
40
|
export default MenuButton;
|
|
41
|
+
export type { Option as MenuButtonOption };
|
|
@@ -16,18 +16,20 @@ import * as __WEBPACK_EXTERNAL_MODULE__utils_search_js_89d5ae26__ from "../utils
|
|
|
16
16
|
import * as __WEBPACK_EXTERNAL_MODULE__utils_useNextContext_js_47529181__ from "../utils/useNextContext.js";
|
|
17
17
|
import * as __WEBPACK_EXTERNAL_MODULE__Button_js_17bdd71d__ from "./Button.js";
|
|
18
18
|
import * as __WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__ from "./MenuButton.module.js";
|
|
19
|
-
const MenuButton = ({ autoFocus = false, disabled = false, id, options, searchPlaceholder, children, icon, iconRight, displaySearch = false })=>{
|
|
19
|
+
const MenuButton = ({ autoFocus = false, disabled = false, id, options, optionGroups, searchPlaceholder, children, icon, iconRight, displaySearch = false, fullWidth = false })=>{
|
|
20
|
+
const listboxId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
21
|
+
const generatedButtonId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
22
|
+
const buttonId = id ?? generatedButtonId;
|
|
20
23
|
const { Link: NextLink } = (0, __WEBPACK_EXTERNAL_MODULE__utils_useNextContext_js_47529181__["default"])();
|
|
21
24
|
const optionsRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)([]);
|
|
22
25
|
const searchRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
23
|
-
const listBoxRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
24
26
|
const [searchTerm, setSearchTerm] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)("");
|
|
25
27
|
const [isOpen, setIsOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
|
|
26
28
|
const [optionToRender, setOptionToRender] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
27
29
|
const [activeIndex, setActiveIndex] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
28
30
|
const [loading, setLoading] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
|
|
29
31
|
const [errors, setErrors] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([]);
|
|
30
|
-
const nonNullOptions = options.filter((option)=>null !== option);
|
|
32
|
+
const nonNullOptions = (options ?? optionGroups.flatMap((group)=>group.options) ?? []).filter((option)=>null !== option);
|
|
31
33
|
const filteredOptions = "" !== searchTerm.trim() ? (0, __WEBPACK_EXTERNAL_MODULE__utils_search_js_89d5ae26__["default"])(nonNullOptions.map((option)=>({
|
|
32
34
|
...option,
|
|
33
35
|
id: option.id
|
|
@@ -51,8 +53,7 @@ const MenuButton = ({ autoFocus = false, disabled = false, id, options, searchPl
|
|
|
51
53
|
(0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.size)({
|
|
52
54
|
apply ({ rects, elements }) {
|
|
53
55
|
Object.assign(elements.floating.style, {
|
|
54
|
-
|
|
55
|
-
maxWidth: rects.reference.width > 200 ? `${rects.reference.width}px` : "200px"
|
|
56
|
+
width: `${Math.max(rects.reference.width, 200)}px`
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
})
|
|
@@ -71,17 +72,114 @@ const MenuButton = ({ autoFocus = false, disabled = false, id, options, searchPl
|
|
|
71
72
|
dismiss,
|
|
72
73
|
listNav
|
|
73
74
|
]);
|
|
75
|
+
const renderOption = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((option, index)=>{
|
|
76
|
+
if ("link" === option.type) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("li", {
|
|
77
|
+
role: "option",
|
|
78
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].listItem, {
|
|
79
|
+
[__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].activeListItem]: activeIndex === index
|
|
80
|
+
}),
|
|
81
|
+
...getItemProps({
|
|
82
|
+
ref: (node)=>{
|
|
83
|
+
optionsRef.current[index] = node;
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(NextLink, {
|
|
87
|
+
href: option.href,
|
|
88
|
+
children: option.label
|
|
89
|
+
})
|
|
90
|
+
}, option.id);
|
|
91
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("li", {
|
|
92
|
+
role: "option",
|
|
93
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].listItem, {
|
|
94
|
+
[__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].activeListItem]: activeIndex === index
|
|
95
|
+
}),
|
|
96
|
+
...getItemProps({
|
|
97
|
+
onClick: "onClick" === option.type ? async (event)=>{
|
|
98
|
+
setIsOpen(false);
|
|
99
|
+
try {
|
|
100
|
+
setLoading(true);
|
|
101
|
+
await option.onClick(event);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error instanceof __WEBPACK_EXTERNAL_MODULE__forms_FormError_js_7d98929f__["default"]) setErrors(error.validationErrors);
|
|
104
|
+
else error instanceof Error ? setErrors([
|
|
105
|
+
{
|
|
106
|
+
id: (0, __WEBPACK_EXTERNAL_MODULE_uuid__.v4)(),
|
|
107
|
+
message: error.message
|
|
108
|
+
}
|
|
109
|
+
]) : setErrors([
|
|
110
|
+
{
|
|
111
|
+
id: (0, __WEBPACK_EXTERNAL_MODULE_uuid__.v4)(),
|
|
112
|
+
message: "Unknown error."
|
|
113
|
+
}
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
setLoading(false);
|
|
117
|
+
} : ()=>{
|
|
118
|
+
setIsOpen(false);
|
|
119
|
+
setOptionToRender(option);
|
|
120
|
+
},
|
|
121
|
+
ref: (node)=>{
|
|
122
|
+
optionsRef.current[index] = node;
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
children: option.label
|
|
126
|
+
}, option.id);
|
|
127
|
+
}, [
|
|
128
|
+
activeIndex,
|
|
129
|
+
getItemProps,
|
|
130
|
+
optionsRef,
|
|
131
|
+
NextLink
|
|
132
|
+
]);
|
|
133
|
+
const renderOptions = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
134
|
+
if (options) return filteredOptions.map(renderOption);
|
|
135
|
+
return optionGroups.map((group)=>{
|
|
136
|
+
if (0 === group.options.length) return null;
|
|
137
|
+
const groupOptionIds = new Set(group.options.map((o)=>o?.id));
|
|
138
|
+
const filteredGroupOptions = filteredOptions.filter((o)=>groupOptionIds.has(o.id));
|
|
139
|
+
if (0 === filteredGroupOptions.length) return null;
|
|
140
|
+
const headerId = `${listboxId}-group-${group.header}`;
|
|
141
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("li", {
|
|
142
|
+
role: "presentation",
|
|
143
|
+
children: [
|
|
144
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
145
|
+
id: headerId,
|
|
146
|
+
className: __WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].listItemGroupHeader,
|
|
147
|
+
children: group.header
|
|
148
|
+
}),
|
|
149
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
|
|
150
|
+
role: "group",
|
|
151
|
+
"aria-labelledby": headerId,
|
|
152
|
+
children: filteredGroupOptions.map((option)=>{
|
|
153
|
+
const optionIndex = optionGroups.flatMap((group)=>group.options).indexOf(option);
|
|
154
|
+
return renderOption(option, optionIndex);
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}, group.header);
|
|
159
|
+
});
|
|
160
|
+
}, [
|
|
161
|
+
filteredOptions,
|
|
162
|
+
optionGroups,
|
|
163
|
+
options,
|
|
164
|
+
renderOption,
|
|
165
|
+
listboxId
|
|
166
|
+
]);
|
|
74
167
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
|
|
75
168
|
children: [
|
|
76
169
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", {
|
|
170
|
+
"aria-controls": listboxId,
|
|
171
|
+
"aria-haspopup": "listbox",
|
|
172
|
+
"aria-expanded": isOpen,
|
|
77
173
|
autoFocus: autoFocus,
|
|
78
174
|
disabled: disabled,
|
|
79
|
-
className: __WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].button,
|
|
175
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].button, {
|
|
176
|
+
[__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].fullWidthButton]: fullWidth
|
|
177
|
+
}),
|
|
80
178
|
tabIndex: 0,
|
|
81
179
|
type: "button",
|
|
82
180
|
ref: floatingUiRefs.setReference,
|
|
83
181
|
...getReferenceProps({
|
|
84
|
-
id:
|
|
182
|
+
id: buttonId
|
|
85
183
|
}),
|
|
86
184
|
children: [
|
|
87
185
|
loading ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__presentation_Icon_js_6961aa57__["default"], {
|
|
@@ -98,90 +196,40 @@ const MenuButton = ({ autoFocus = false, disabled = false, id, options, searchPl
|
|
|
98
196
|
}) : null
|
|
99
197
|
]
|
|
100
198
|
}),
|
|
101
|
-
!disabled && isOpen ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
102
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}),
|
|
136
|
-
...getItemProps({
|
|
137
|
-
ref: (node)=>{
|
|
138
|
-
optionsRef.current[index] = node;
|
|
139
|
-
}
|
|
140
|
-
}),
|
|
141
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(NextLink, {
|
|
142
|
-
href: option.href,
|
|
143
|
-
children: option.label
|
|
144
|
-
})
|
|
145
|
-
}, option.id);
|
|
146
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("li", {
|
|
147
|
-
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].listItem, {
|
|
148
|
-
[__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].activeListItem]: activeIndex === index
|
|
149
|
-
}),
|
|
150
|
-
...getItemProps({
|
|
151
|
-
onClick: "onClick" === option.type ? async (event)=>{
|
|
152
|
-
setIsOpen(false);
|
|
153
|
-
try {
|
|
154
|
-
setLoading(true);
|
|
155
|
-
await option.onClick(event);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
if (error instanceof __WEBPACK_EXTERNAL_MODULE__forms_FormError_js_7d98929f__["default"]) setErrors(error.validationErrors);
|
|
158
|
-
else error instanceof Error ? setErrors([
|
|
159
|
-
{
|
|
160
|
-
id: (0, __WEBPACK_EXTERNAL_MODULE_uuid__.v4)(),
|
|
161
|
-
message: error.message
|
|
162
|
-
}
|
|
163
|
-
]) : setErrors([
|
|
164
|
-
{
|
|
165
|
-
id: (0, __WEBPACK_EXTERNAL_MODULE_uuid__.v4)(),
|
|
166
|
-
message: "Unknown error."
|
|
167
|
-
}
|
|
168
|
-
]);
|
|
169
|
-
}
|
|
170
|
-
setLoading(false);
|
|
171
|
-
} : ()=>{
|
|
172
|
-
setIsOpen(false);
|
|
173
|
-
setOptionToRender(option);
|
|
174
|
-
},
|
|
175
|
-
ref: (node)=>{
|
|
176
|
-
optionsRef.current[index] = node;
|
|
177
|
-
}
|
|
178
|
-
}),
|
|
179
|
-
children: option.label
|
|
180
|
-
}, option.id);
|
|
181
|
-
})
|
|
182
|
-
}) : null
|
|
183
|
-
]
|
|
184
|
-
})
|
|
199
|
+
!disabled && isOpen ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.FloatingPortal, {
|
|
200
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.FloatingFocusManager, {
|
|
201
|
+
context: context,
|
|
202
|
+
initialFocus: searchRef,
|
|
203
|
+
modal: false,
|
|
204
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
205
|
+
ref: floatingUiRefs.setFloating,
|
|
206
|
+
style: floatingStyles,
|
|
207
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].menu),
|
|
208
|
+
...getFloatingProps(),
|
|
209
|
+
children: [
|
|
210
|
+
displaySearch ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("input", {
|
|
211
|
+
type: "text",
|
|
212
|
+
className: __WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].searchInput,
|
|
213
|
+
placeholder: searchPlaceholder ?? "Search for an option",
|
|
214
|
+
"aria-autocomplete": "list",
|
|
215
|
+
onChange: (e)=>{
|
|
216
|
+
setSearchTerm(e.target.value);
|
|
217
|
+
setActiveIndex(0);
|
|
218
|
+
},
|
|
219
|
+
value: searchTerm,
|
|
220
|
+
ref: searchRef,
|
|
221
|
+
onKeyDown: (event)=>{
|
|
222
|
+
if ("Enter" === event.key && null != activeIndex) setIsOpen(false);
|
|
223
|
+
}
|
|
224
|
+
}) : null,
|
|
225
|
+
0 !== filteredOptions.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
|
|
226
|
+
className: __WEBPACK_EXTERNAL_MODULE__MenuButton_module_js_872b1a55__["default"].listBox,
|
|
227
|
+
id: listboxId,
|
|
228
|
+
role: "listbox",
|
|
229
|
+
"aria-labelledby": buttonId,
|
|
230
|
+
children: renderOptions()
|
|
231
|
+
}) : null
|
|
232
|
+
]
|
|
185
233
|
})
|
|
186
234
|
})
|
|
187
235
|
}) : null,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import "./MenuButton_module.css";
|
|
2
2
|
const MenuButton_module_rslib_entry_ = {
|
|
3
3
|
button: "button-HIHLjl",
|
|
4
|
+
fullWidthButton: "fullWidthButton-Q2zYOT",
|
|
4
5
|
searchInput: "searchInput-bGdium",
|
|
5
6
|
menu: "menu-jQY3kP",
|
|
6
7
|
listBox: "listBox-IanUVy",
|
|
8
|
+
listItemGroupHeader: "listItemGroupHeader-ijzhOF",
|
|
7
9
|
listItem: "listItem-PEQEDL",
|
|
8
10
|
activeListItem: "activeListItem-iAlKFS"
|
|
9
11
|
};
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
background-color: var(--color-grey-t08);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
.fullWidthButton-Q2zYOT {
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
.button-HIHLjl:disabled {
|
|
27
31
|
background: var(--color-grey-t09);
|
|
28
32
|
border-color: var(--color-grey-t09);
|
|
@@ -59,6 +63,11 @@
|
|
|
59
63
|
overflow-y: auto;
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
.listItemGroupHeader-ijzhOF {
|
|
67
|
+
padding: var(--size-n2) var(--size-n2) var(--size-n2) 0;
|
|
68
|
+
font: var(--font-regular-bold);
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
.listItem-PEQEDL {
|
|
63
72
|
padding: var(--size-n2);
|
|
64
73
|
border-radius: var(--size-n3);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Dispatch, type ReactNode } from "react";
|
|
2
2
|
import type { ValidationError } from "../forms/_types";
|
|
3
3
|
type Props<Option> = {
|
|
4
4
|
autoFocus?: boolean;
|
|
@@ -6,7 +6,6 @@ type Props<Option> = {
|
|
|
6
6
|
id: string;
|
|
7
7
|
includeValueInTracking?: boolean;
|
|
8
8
|
onChange: Dispatch<Option>;
|
|
9
|
-
options: Array<Option>;
|
|
10
9
|
optionToId: (option: Option) => string;
|
|
11
10
|
optionToLabel: (option: Option) => ReactNode;
|
|
12
11
|
value: Option | null;
|
|
@@ -20,6 +19,15 @@ type Props<Option> = {
|
|
|
20
19
|
label: ReactNode;
|
|
21
20
|
labelFont?: "heading" | "subheading" | "label" | "regular-bold" | "regular";
|
|
22
21
|
required?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
22
|
+
} & ({
|
|
23
|
+
options: Array<Option>;
|
|
24
|
+
optionGroups?: never;
|
|
25
|
+
} | {
|
|
26
|
+
options?: never;
|
|
27
|
+
optionGroups: Array<{
|
|
28
|
+
header: string;
|
|
29
|
+
options: Array<Option>;
|
|
30
|
+
}>;
|
|
31
|
+
});
|
|
32
|
+
declare const SingleSelectComboBoxField: <Option>({ autoFocus, disabled, id, includeValueInTracking, onChange, options, optionGroups, optionToId, optionToLabel, value, placeholder, searchPlaceholder, searchFields, onCreate, onClear, description, errors, label, labelFont, required, }: Props<Option>) => import("react/jsx-runtime").JSX.Element;
|
|
25
33
|
export default SingleSelectComboBoxField;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE__forms_RegularField_js_c54537ba__ from "../forms/RegularField.js";
|
|
3
4
|
import * as __WEBPACK_EXTERNAL_MODULE__inputs_SingleSelectComboboxInput_js_15b92560__ from "../inputs/SingleSelectComboboxInput.js";
|
|
4
|
-
const SingleSelectComboBoxField = ({ autoFocus = false, disabled = false, id, includeValueInTracking, onChange, options, optionToId, optionToLabel, value, placeholder, searchPlaceholder, searchFields, onCreate, onClear, description, errors, label, labelFont = "label", required = false })
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
label: label,
|
|
8
|
-
labelFont: labelFont,
|
|
9
|
-
required: required,
|
|
10
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_SingleSelectComboboxInput_js_15b92560__["default"], {
|
|
5
|
+
const SingleSelectComboBoxField = ({ autoFocus = false, disabled = false, id, includeValueInTracking, onChange, options, optionGroups, optionToId, optionToLabel, value, placeholder, searchPlaceholder, searchFields, onCreate, onClear, description, errors, label, labelFont = "label", required = false })=>{
|
|
6
|
+
const comboboxInput = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
7
|
+
if (options) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_SingleSelectComboboxInput_js_15b92560__["default"], {
|
|
11
8
|
autoFocus: autoFocus,
|
|
12
9
|
disabled: disabled,
|
|
13
10
|
id: id,
|
|
@@ -22,7 +19,48 @@ const SingleSelectComboBoxField = ({ autoFocus = false, disabled = false, id, in
|
|
|
22
19
|
searchFields: searchFields,
|
|
23
20
|
onCreate: onCreate,
|
|
24
21
|
onClear: onClear
|
|
25
|
-
})
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_SingleSelectComboboxInput_js_15b92560__["default"], {
|
|
24
|
+
autoFocus: autoFocus,
|
|
25
|
+
disabled: disabled,
|
|
26
|
+
id: id,
|
|
27
|
+
includeValueInTracking: includeValueInTracking,
|
|
28
|
+
onChange: onChange,
|
|
29
|
+
optionGroups: optionGroups,
|
|
30
|
+
optionToId: optionToId,
|
|
31
|
+
optionToLabel: optionToLabel,
|
|
32
|
+
value: value,
|
|
33
|
+
placeholder: placeholder,
|
|
34
|
+
searchPlaceholder: searchPlaceholder,
|
|
35
|
+
searchFields: searchFields,
|
|
36
|
+
onCreate: onCreate,
|
|
37
|
+
onClear: onClear
|
|
38
|
+
});
|
|
39
|
+
}, [
|
|
40
|
+
autoFocus,
|
|
41
|
+
disabled,
|
|
42
|
+
id,
|
|
43
|
+
includeValueInTracking,
|
|
44
|
+
onChange,
|
|
45
|
+
optionGroups,
|
|
46
|
+
optionToId,
|
|
47
|
+
optionToLabel,
|
|
48
|
+
value,
|
|
49
|
+
placeholder,
|
|
50
|
+
searchPlaceholder,
|
|
51
|
+
searchFields,
|
|
52
|
+
onCreate,
|
|
53
|
+
onClear,
|
|
54
|
+
options
|
|
55
|
+
]);
|
|
56
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__forms_RegularField_js_c54537ba__["default"], {
|
|
57
|
+
description: description,
|
|
58
|
+
errors: errors,
|
|
59
|
+
label: label,
|
|
60
|
+
labelFont: labelFont,
|
|
61
|
+
required: required,
|
|
62
|
+
children: comboboxInput
|
|
26
63
|
});
|
|
64
|
+
};
|
|
27
65
|
const SingleSelectComboboxField_rslib_entry_ = SingleSelectComboBoxField;
|
|
28
66
|
export { SingleSelectComboboxField_rslib_entry_ as default };
|
|
@@ -5,7 +5,6 @@ type Props<Option> = {
|
|
|
5
5
|
id: string;
|
|
6
6
|
includeValueInTracking?: boolean;
|
|
7
7
|
onChange: Dispatch<Option>;
|
|
8
|
-
options: Array<Option>;
|
|
9
8
|
optionToId: (option: Option) => string;
|
|
10
9
|
optionToLabel: (option: Option) => ReactNode;
|
|
11
10
|
value: Option | null;
|
|
@@ -14,6 +13,15 @@ type Props<Option> = {
|
|
|
14
13
|
searchFields: Array<keyof Option & string>;
|
|
15
14
|
onCreate?: (onClose: () => void, searchTerm: string) => ReactNode;
|
|
16
15
|
onClear?: () => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
16
|
+
} & ({
|
|
17
|
+
options: Array<Option>;
|
|
18
|
+
optionGroups?: never;
|
|
19
|
+
} | {
|
|
20
|
+
options?: never;
|
|
21
|
+
optionGroups: Array<{
|
|
22
|
+
header: string;
|
|
23
|
+
options: Array<Option>;
|
|
24
|
+
}>;
|
|
25
|
+
});
|
|
26
|
+
declare const SingleSelectComboBoxInput: <Option>({ autoFocus, disabled, id, onChange, options, optionGroups, optionToId, optionToLabel, value, placeholder, searchPlaceholder, searchFields, onCreate, onClear, }: Props<Option>) => import("react/jsx-runtime").JSX.Element;
|
|
19
27
|
export default SingleSelectComboBoxInput;
|
|
@@ -5,7 +5,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__presentation_Icon_js_6961aa57__ from "../presentation/Icon.js";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__utils_search_js_89d5ae26__ from "../utils/search.js";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__ from "./SingleSelectComboboxInput.module.js";
|
|
8
|
-
const SingleSelectComboBoxInput = ({ autoFocus = false, disabled = false, id, onChange, options, optionToId, optionToLabel, value, placeholder, searchPlaceholder, searchFields, onCreate, onClear })=>{
|
|
8
|
+
const SingleSelectComboBoxInput = ({ autoFocus = false, disabled = false, id, onChange, options, optionGroups, optionToId, optionToLabel, value, placeholder, searchPlaceholder, searchFields, onCreate, onClear })=>{
|
|
9
|
+
const listboxId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
10
|
+
const buttonId = id;
|
|
9
11
|
const optionsRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)([]);
|
|
10
12
|
const searchRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
11
13
|
const listBoxRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
@@ -13,10 +15,16 @@ const SingleSelectComboBoxInput = ({ autoFocus = false, disabled = false, id, on
|
|
|
13
15
|
const [createNewOption, setCreateNewOption] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
|
|
14
16
|
const [isOpen, setIsOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
|
|
15
17
|
const [activeIndex, setActiveIndex] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(0);
|
|
16
|
-
const filteredOptions = "" !== searchTerm.trim() ? (0, __WEBPACK_EXTERNAL_MODULE__utils_search_js_89d5ae26__["default"])(options.map((option)=>({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const filteredOptions = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>"" !== searchTerm.trim() ? (0, __WEBPACK_EXTERNAL_MODULE__utils_search_js_89d5ae26__["default"])((options ?? optionGroups.flatMap((group)=>group.options) ?? []).map((option)=>({
|
|
19
|
+
...option,
|
|
20
|
+
id: optionToId(option)
|
|
21
|
+
})), searchFields, searchTerm) : options ?? optionGroups.flatMap((group)=>group.options) ?? [], [
|
|
22
|
+
options,
|
|
23
|
+
optionGroups,
|
|
24
|
+
searchFields,
|
|
25
|
+
searchTerm,
|
|
26
|
+
optionToId
|
|
27
|
+
]);
|
|
20
28
|
const { refs: floatingUiRefs, floatingStyles, context } = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.useFloating)({
|
|
21
29
|
open: isOpen,
|
|
22
30
|
onOpenChange: (open)=>{
|
|
@@ -54,9 +62,79 @@ const SingleSelectComboBoxInput = ({ autoFocus = false, disabled = false, id, on
|
|
|
54
62
|
dismiss,
|
|
55
63
|
listNav
|
|
56
64
|
]);
|
|
65
|
+
const renderOption = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((option, index)=>{
|
|
66
|
+
const optionId = optionToId(option);
|
|
67
|
+
const optionLabel = optionToLabel(option);
|
|
68
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("li", {
|
|
69
|
+
role: "option",
|
|
70
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listItem, {
|
|
71
|
+
[__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].activeListItem]: activeIndex === index
|
|
72
|
+
}),
|
|
73
|
+
...getItemProps({
|
|
74
|
+
onClick: ()=>{
|
|
75
|
+
setIsOpen(false);
|
|
76
|
+
onChange(option);
|
|
77
|
+
},
|
|
78
|
+
ref: (node)=>{
|
|
79
|
+
optionsRef.current[index] = node;
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
children: [
|
|
83
|
+
optionLabel,
|
|
84
|
+
value && optionToId(value) === optionToId(option) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__presentation_Icon_js_6961aa57__["default"], {
|
|
85
|
+
symbol: "CheckMark"
|
|
86
|
+
}) : null
|
|
87
|
+
]
|
|
88
|
+
}, optionId);
|
|
89
|
+
}, [
|
|
90
|
+
activeIndex,
|
|
91
|
+
onChange,
|
|
92
|
+
optionToId,
|
|
93
|
+
optionToLabel,
|
|
94
|
+
value,
|
|
95
|
+
getItemProps
|
|
96
|
+
]);
|
|
97
|
+
const renderOptions = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
98
|
+
if (options) return filteredOptions.map(renderOption);
|
|
99
|
+
return optionGroups.map((group)=>{
|
|
100
|
+
if (0 === group.options.length) return null;
|
|
101
|
+
const groupOptionIds = new Set(group.options.map((o)=>optionToId(o)));
|
|
102
|
+
const filteredGroupOptions = filteredOptions.filter((o)=>groupOptionIds.has(optionToId(o)));
|
|
103
|
+
if (0 === filteredGroupOptions.length) return null;
|
|
104
|
+
const headerId = `${listboxId}-group-${group.header}`;
|
|
105
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("li", {
|
|
106
|
+
role: "presentation",
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
109
|
+
id: headerId,
|
|
110
|
+
className: __WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listItemGroupHeader,
|
|
111
|
+
children: group.header
|
|
112
|
+
}),
|
|
113
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
|
|
114
|
+
role: "group",
|
|
115
|
+
"aria-labelledby": headerId,
|
|
116
|
+
children: filteredGroupOptions.map((option)=>{
|
|
117
|
+
const optionIndex = optionGroups.flatMap((group)=>group.options).indexOf(option);
|
|
118
|
+
return renderOption(option, optionIndex);
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}, group.header);
|
|
123
|
+
});
|
|
124
|
+
}, [
|
|
125
|
+
filteredOptions,
|
|
126
|
+
listboxId,
|
|
127
|
+
optionGroups,
|
|
128
|
+
optionToId,
|
|
129
|
+
renderOption,
|
|
130
|
+
options
|
|
131
|
+
]);
|
|
57
132
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
|
|
58
133
|
children: [
|
|
59
134
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", {
|
|
135
|
+
"aria-controls": listboxId,
|
|
136
|
+
"aria-haspopup": "listbox",
|
|
137
|
+
"aria-expanded": isOpen,
|
|
60
138
|
autoFocus: autoFocus,
|
|
61
139
|
disabled: disabled,
|
|
62
140
|
className: __WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].toggleButton,
|
|
@@ -64,7 +142,7 @@ const SingleSelectComboBoxInput = ({ autoFocus = false, disabled = false, id, on
|
|
|
64
142
|
type: "button",
|
|
65
143
|
ref: floatingUiRefs.setReference,
|
|
66
144
|
...getReferenceProps({
|
|
67
|
-
id:
|
|
145
|
+
id: buttonId
|
|
68
146
|
}),
|
|
69
147
|
children: [
|
|
70
148
|
value ? optionToLabel(value) : placeholder ?? "Select an option",
|
|
@@ -90,82 +168,60 @@ const SingleSelectComboBoxInput = ({ autoFocus = false, disabled = false, id, on
|
|
|
90
168
|
})
|
|
91
169
|
]
|
|
92
170
|
}),
|
|
93
|
-
!disabled && isOpen ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
94
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onChange(filteredOptions[activeIndex]);
|
|
120
|
-
}
|
|
171
|
+
!disabled && isOpen ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.FloatingPortal, {
|
|
172
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.FloatingFocusManager, {
|
|
173
|
+
context: context,
|
|
174
|
+
initialFocus: searchRef,
|
|
175
|
+
modal: false,
|
|
176
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
177
|
+
ref: floatingUiRefs.setFloating,
|
|
178
|
+
style: floatingStyles,
|
|
179
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].menu),
|
|
180
|
+
...getFloatingProps(),
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("input", {
|
|
183
|
+
type: "text",
|
|
184
|
+
className: __WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].searchInput,
|
|
185
|
+
placeholder: searchPlaceholder ?? "Search for an option",
|
|
186
|
+
"aria-autocomplete": "list",
|
|
187
|
+
onChange: (e)=>{
|
|
188
|
+
setSearchTerm(e.target.value);
|
|
189
|
+
setActiveIndex(0);
|
|
190
|
+
},
|
|
191
|
+
value: searchTerm,
|
|
192
|
+
ref: searchRef,
|
|
193
|
+
onKeyDown: (e)=>{
|
|
194
|
+
if ("Enter" === e.key && null != activeIndex) {
|
|
195
|
+
setIsOpen(false);
|
|
196
|
+
onChange(filteredOptions[activeIndex]);
|
|
121
197
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}, optionId);
|
|
150
|
-
}),
|
|
151
|
-
onCreate ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("li", {
|
|
152
|
-
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
|
|
153
|
-
__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listItem,
|
|
154
|
-
__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listItemCreate
|
|
155
|
-
]),
|
|
156
|
-
onClick: ()=>{
|
|
157
|
-
setIsOpen(false);
|
|
158
|
-
setCreateNewOption(true);
|
|
159
|
-
},
|
|
160
|
-
children: [
|
|
161
|
-
"+ Create new option ",
|
|
162
|
-
searchTerm ? `"${searchTerm}"` : null
|
|
163
|
-
]
|
|
164
|
-
}) : null
|
|
165
|
-
]
|
|
166
|
-
}) : null
|
|
167
|
-
]
|
|
168
|
-
})
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
0 !== filteredOptions.length || onCreate ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("ul", {
|
|
201
|
+
className: __WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listBox,
|
|
202
|
+
ref: listBoxRef,
|
|
203
|
+
id: listboxId,
|
|
204
|
+
role: "listbox",
|
|
205
|
+
"aria-labelledby": buttonId,
|
|
206
|
+
children: [
|
|
207
|
+
renderOptions(),
|
|
208
|
+
onCreate ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("li", {
|
|
209
|
+
className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
|
|
210
|
+
__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listItem,
|
|
211
|
+
__WEBPACK_EXTERNAL_MODULE__SingleSelectComboboxInput_module_js_54aa53da__["default"].listItemCreate
|
|
212
|
+
]),
|
|
213
|
+
onClick: ()=>{
|
|
214
|
+
setIsOpen(false);
|
|
215
|
+
setCreateNewOption(true);
|
|
216
|
+
},
|
|
217
|
+
children: [
|
|
218
|
+
"+ Create new option ",
|
|
219
|
+
searchTerm ? `"${searchTerm}"` : null
|
|
220
|
+
]
|
|
221
|
+
}) : null
|
|
222
|
+
]
|
|
223
|
+
}) : null
|
|
224
|
+
]
|
|
169
225
|
})
|
|
170
226
|
})
|
|
171
227
|
}) : null,
|
|
@@ -5,6 +5,7 @@ const SingleSelectComboboxInput_module_rslib_entry_ = {
|
|
|
5
5
|
searchInput: "searchInput-s9NjcM",
|
|
6
6
|
menu: "menu-f81oko",
|
|
7
7
|
listBox: "listBox-biTMkv",
|
|
8
|
+
listItemGroupHeader: "listItemGroupHeader-SdoaP2",
|
|
8
9
|
listItem: "listItem-ASZkke",
|
|
9
10
|
listItemCreate: "listItemCreate-_tGId1",
|
|
10
11
|
activeListItem: "activeListItem-_B_E3X"
|
|
@@ -20,10 +20,10 @@ const Tooltip = ({ children, content })=>{
|
|
|
20
20
|
whileElementsMounted: __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.autoUpdate
|
|
21
21
|
});
|
|
22
22
|
const hover = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.useHover)(context, {
|
|
23
|
-
move:
|
|
24
|
-
restMs:
|
|
23
|
+
move: true,
|
|
24
|
+
restMs: 50,
|
|
25
25
|
delay: {
|
|
26
|
-
open:
|
|
26
|
+
open: 0,
|
|
27
27
|
close: 0
|
|
28
28
|
}
|
|
29
29
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_temporal_polyfill_11c1db1c__ from "temporal-polyfill";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_uuid__ from "uuid";
|
|
3
|
+
const isValidDate = (field, message = "Invalid date.")=>(data)=>{
|
|
4
|
+
const value = data[field];
|
|
5
|
+
if (null == value) return null;
|
|
6
|
+
if ("string" == typeof value && "" !== value.trim()) try {
|
|
7
|
+
__WEBPACK_EXTERNAL_MODULE_temporal_polyfill_11c1db1c__.Temporal.PlainDate.from(value);
|
|
8
|
+
} catch {
|
|
9
|
+
return {
|
|
10
|
+
id: (0, __WEBPACK_EXTERNAL_MODULE_uuid__.v4)(),
|
|
11
|
+
field,
|
|
12
|
+
message
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
const isValidDate_rslib_entry_ = isValidDate;
|
|
18
|
+
export { isValidDate_rslib_entry_ as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/whiteboard",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-markdown": "^10.1.0",
|
|
39
39
|
"utf8": "^3.0.0",
|
|
40
40
|
"zod": "^3.22.3",
|
|
41
|
-
"@worknice/utils": "^0.6.
|
|
41
|
+
"@worknice/utils": "^0.6.36"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@anolilab/semantic-release-pnpm": "^1.1.10",
|