@uipath/apollo-wind 2.56.0 → 2.57.1
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/components/ui/alert-dialog.cjs +7 -6
- package/dist/components/ui/alert-dialog.js +7 -6
- package/dist/components/ui/code-editors.shared.cjs +323 -0
- package/dist/components/ui/code-editors.shared.d.ts +936 -0
- package/dist/components/ui/code-editors.shared.js +264 -0
- package/dist/components/ui/combobox.cjs +33 -15
- package/dist/components/ui/combobox.js +33 -15
- package/dist/components/ui/date-picker.cjs +62 -26
- package/dist/components/ui/date-picker.js +62 -26
- package/dist/components/ui/datetime-picker.cjs +29 -12
- package/dist/components/ui/datetime-picker.js +29 -12
- package/dist/components/ui/dialog.cjs +2 -1
- package/dist/components/ui/dialog.js +2 -1
- package/dist/components/ui/dropdown-menu.cjs +12 -8
- package/dist/components/ui/dropdown-menu.js +12 -8
- package/dist/components/ui/field-actions/ai-assist-action.cjs +121 -0
- package/dist/components/ui/field-actions/ai-assist-action.d.ts +21 -0
- package/dist/components/ui/field-actions/ai-assist-action.js +84 -0
- package/dist/components/ui/field-actions/collapse.cjs +44 -0
- package/dist/components/ui/field-actions/collapse.d.ts +6 -0
- package/dist/components/ui/field-actions/collapse.js +4 -0
- package/dist/components/ui/field-actions/index.cjs +46 -0
- package/dist/components/ui/field-actions/index.d.ts +2 -0
- package/dist/components/ui/field-actions/index.js +3 -0
- package/dist/components/ui/field-actions/insert-variable-action.cjs +94 -0
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +22 -0
- package/dist/components/ui/field-actions/insert-variable-action.js +57 -0
- package/dist/components/ui/field-addons/index.cjs +50 -0
- package/dist/components/ui/field-addons/index.d.ts +3 -0
- package/dist/components/ui/field-addons/index.js +4 -0
- package/dist/components/ui/field-addons/value-mode-indicator.cjs +57 -0
- package/dist/components/ui/field-addons/value-mode-indicator.d.ts +13 -0
- package/dist/components/ui/field-addons/value-mode-indicator.js +23 -0
- package/dist/components/ui/field-addons/value-mode-menu.cjs +149 -0
- package/dist/components/ui/field-addons/value-mode-menu.d.ts +69 -0
- package/dist/components/ui/field-addons/value-mode-menu.js +112 -0
- package/dist/components/ui/field-addons/value-mode-strings.cjs +69 -0
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +32 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +29 -0
- package/dist/components/ui/form-field.cjs +42 -5
- package/dist/components/ui/form-field.d.ts +21 -1
- package/dist/components/ui/form-field.js +36 -2
- package/dist/components/ui/index.cjs +150 -130
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/input-group-context.cjs +91 -0
- package/dist/components/ui/input-group-context.d.ts +69 -0
- package/dist/components/ui/input-group-context.js +42 -0
- package/dist/components/ui/input-group.cjs +303 -56
- package/dist/components/ui/input-group.d.ts +70 -3
- package/dist/components/ui/input-group.js +285 -56
- package/dist/components/ui/input.cjs +28 -17
- package/dist/components/ui/input.js +28 -17
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +16 -114
- package/dist/components/ui/lockable-value-field/components/field-header.js +14 -112
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +4 -12
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +4 -12
- package/dist/components/ui/multi-select.cjs +82 -58
- package/dist/components/ui/multi-select.js +84 -60
- package/dist/components/ui/popover.cjs +13 -9
- package/dist/components/ui/popover.js +13 -9
- package/dist/components/ui/select.cjs +89 -27
- package/dist/components/ui/select.d.ts +4 -0
- package/dist/components/ui/select.js +90 -28
- package/dist/components/ui/textarea.cjs +16 -11
- package/dist/components/ui/textarea.js +16 -11
- package/dist/index.cjs +61 -11
- package/dist/index.d.ts +8 -4
- package/dist/index.js +5 -3
- package/dist/lib/dialog-surface.cjs +36 -0
- package/dist/lib/dialog-surface.d.ts +1 -0
- package/dist/lib/dialog-surface.js +2 -0
- package/dist/styles.css +249 -14
- package/package.json +1 -1
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.cjs +0 -63
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.d.ts +0 -9
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.js +0 -29
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import react from "@monaco-editor/react";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { apolloCoreDarkCodeMirror, apolloCoreDarkHCCodeMirror, apolloCoreDarkHCMonaco, apolloCoreDarkMonaco, apolloCoreLightCodeMirror, apolloCoreLightHCCodeMirror, apolloCoreLightHCMonaco, apolloCoreLightMonaco, apolloFutureDarkCodeMirror, apolloFutureDarkMonaco, apolloFutureLightCodeMirror, apolloFutureLightMonaco } from "../../editor-themes/index.js";
|
|
5
|
+
const editorThemeConfigs = [
|
|
6
|
+
{
|
|
7
|
+
key: 'future-dark',
|
|
8
|
+
label: 'Future Dark',
|
|
9
|
+
monacoThemeName: 'apollo-future-dark',
|
|
10
|
+
monacoExport: 'apolloFutureDarkMonaco',
|
|
11
|
+
cmExport: 'apolloFutureDarkCodeMirror',
|
|
12
|
+
monacoThemeObj: apolloFutureDarkMonaco,
|
|
13
|
+
cmTokens: apolloFutureDarkCodeMirror,
|
|
14
|
+
isDark: true,
|
|
15
|
+
family: 'Future'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
key: 'future-light',
|
|
19
|
+
label: 'Future Light',
|
|
20
|
+
monacoThemeName: 'apollo-future-light',
|
|
21
|
+
monacoExport: 'apolloFutureLightMonaco',
|
|
22
|
+
cmExport: 'apolloFutureLightCodeMirror',
|
|
23
|
+
monacoThemeObj: apolloFutureLightMonaco,
|
|
24
|
+
cmTokens: apolloFutureLightCodeMirror,
|
|
25
|
+
isDark: false,
|
|
26
|
+
family: 'Future'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
key: 'dark',
|
|
30
|
+
label: 'Dark',
|
|
31
|
+
monacoThemeName: 'apollo-core-dark',
|
|
32
|
+
monacoExport: 'apolloCoreDarkMonaco',
|
|
33
|
+
cmExport: 'apolloCoreDarkCodeMirror',
|
|
34
|
+
monacoThemeObj: apolloCoreDarkMonaco,
|
|
35
|
+
cmTokens: apolloCoreDarkCodeMirror,
|
|
36
|
+
isDark: true,
|
|
37
|
+
family: 'Core'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: 'light',
|
|
41
|
+
label: 'Light',
|
|
42
|
+
monacoThemeName: 'apollo-core-light',
|
|
43
|
+
monacoExport: 'apolloCoreLightMonaco',
|
|
44
|
+
cmExport: 'apolloCoreLightCodeMirror',
|
|
45
|
+
monacoThemeObj: apolloCoreLightMonaco,
|
|
46
|
+
cmTokens: apolloCoreLightCodeMirror,
|
|
47
|
+
isDark: false,
|
|
48
|
+
family: 'Core'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'dark-hc',
|
|
52
|
+
label: 'Dark High Contrast',
|
|
53
|
+
monacoThemeName: 'apollo-core-dark-hc',
|
|
54
|
+
monacoExport: 'apolloCoreDarkHCMonaco',
|
|
55
|
+
cmExport: 'apolloCoreDarkHCCodeMirror',
|
|
56
|
+
monacoThemeObj: apolloCoreDarkHCMonaco,
|
|
57
|
+
cmTokens: apolloCoreDarkHCCodeMirror,
|
|
58
|
+
isDark: true,
|
|
59
|
+
family: 'Core HC'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: 'light-hc',
|
|
63
|
+
label: 'Light High Contrast',
|
|
64
|
+
monacoThemeName: 'apollo-core-light-hc',
|
|
65
|
+
monacoExport: 'apolloCoreLightHCMonaco',
|
|
66
|
+
cmExport: 'apolloCoreLightHCCodeMirror',
|
|
67
|
+
monacoThemeObj: apolloCoreLightHCMonaco,
|
|
68
|
+
cmTokens: apolloCoreLightHCCodeMirror,
|
|
69
|
+
isDark: false,
|
|
70
|
+
family: 'Core HC'
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
const monacoFullSample = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
74
|
+
|
|
75
|
+
type SortDirection = 'asc' | 'desc';
|
|
76
|
+
|
|
77
|
+
interface Column<T> {
|
|
78
|
+
key: keyof T;
|
|
79
|
+
header: string;
|
|
80
|
+
sortable?: boolean;
|
|
81
|
+
render?: (value: T[keyof T], row: T) => ReactNode;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface TableProps<T> {
|
|
85
|
+
data: T[];
|
|
86
|
+
columns: Column<T>[];
|
|
87
|
+
pageSize?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function DataTable<T extends { id: string | number }>({
|
|
91
|
+
data,
|
|
92
|
+
columns,
|
|
93
|
+
pageSize = 10,
|
|
94
|
+
}: TableProps<T>) {
|
|
95
|
+
const [query, setQuery] = useState('');
|
|
96
|
+
const [sortKey, setSortKey] = useState<keyof T | null>(null);
|
|
97
|
+
const [sortDir, setSortDir] = useState<SortDirection>('asc');
|
|
98
|
+
const [page, setPage] = useState(1);
|
|
99
|
+
|
|
100
|
+
useEffect(() => { setPage(1); }, [query, sortKey, sortDir]);
|
|
101
|
+
|
|
102
|
+
const filtered = useMemo(() => {
|
|
103
|
+
if (!query.trim()) return data;
|
|
104
|
+
const q = query.toLowerCase();
|
|
105
|
+
return data.filter((row) =>
|
|
106
|
+
columns.some((col) => String(row[col.key]).toLowerCase().includes(q))
|
|
107
|
+
);
|
|
108
|
+
}, [data, columns, query]);
|
|
109
|
+
|
|
110
|
+
const sorted = useMemo(() => {
|
|
111
|
+
if (!sortKey) return filtered;
|
|
112
|
+
return [...filtered].sort((a, b) => {
|
|
113
|
+
const cmp = a[sortKey] < b[sortKey] ? -1 : a[sortKey] > b[sortKey] ? 1 : 0;
|
|
114
|
+
return sortDir === 'asc' ? cmp : -cmp;
|
|
115
|
+
});
|
|
116
|
+
}, [filtered, sortKey, sortDir]);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="flex flex-col gap-4">
|
|
120
|
+
<input
|
|
121
|
+
className="rounded-lg border border-border px-3 py-2 text-sm"
|
|
122
|
+
placeholder="Search..."
|
|
123
|
+
value={query}
|
|
124
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
125
|
+
/>
|
|
126
|
+
<table className="w-full text-sm">
|
|
127
|
+
<thead>
|
|
128
|
+
<tr className="border-b border-border">
|
|
129
|
+
{columns.map((col) => (
|
|
130
|
+
<th key={String(col.key)} className="px-4 py-2 text-left">
|
|
131
|
+
{col.header}
|
|
132
|
+
</th>
|
|
133
|
+
))}
|
|
134
|
+
</tr>
|
|
135
|
+
</thead>
|
|
136
|
+
</table>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
}`.trim();
|
|
140
|
+
const monacoSample = `interface WorkflowNode {
|
|
141
|
+
id: string;
|
|
142
|
+
type: 'action' | 'condition' | 'trigger';
|
|
143
|
+
executionStatus: 'NotExecuted' | 'InProgress' | 'Completed' | 'Failed';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getNextNodes(node: WorkflowNode): string[] {
|
|
147
|
+
if (node.executionStatus === 'Completed') {
|
|
148
|
+
return node.type === 'condition'
|
|
149
|
+
? ['true-branch', 'false-branch']
|
|
150
|
+
: ['next'];
|
|
151
|
+
}
|
|
152
|
+
return [];
|
|
153
|
+
}`.trim();
|
|
154
|
+
let monacoThemesRegistered = false;
|
|
155
|
+
function registerAllMonacoThemes(monaco) {
|
|
156
|
+
if (monacoThemesRegistered) return;
|
|
157
|
+
for (const cfg of editorThemeConfigs)monaco.editor.defineTheme(cfg.monacoThemeName, cfg.monacoThemeObj);
|
|
158
|
+
monacoThemesRegistered = true;
|
|
159
|
+
}
|
|
160
|
+
let demoDefaultsUsers = 0;
|
|
161
|
+
let savedTypescriptDefaults = null;
|
|
162
|
+
function acquireDemoTypescriptDefaults(monaco) {
|
|
163
|
+
demoDefaultsUsers += 1;
|
|
164
|
+
if (demoDefaultsUsers > 1) return;
|
|
165
|
+
const ts = monaco.languages.typescript.typescriptDefaults;
|
|
166
|
+
savedTypescriptDefaults = {
|
|
167
|
+
diagnostics: ts.getDiagnosticsOptions(),
|
|
168
|
+
compiler: ts.getCompilerOptions()
|
|
169
|
+
};
|
|
170
|
+
ts.setDiagnosticsOptions({
|
|
171
|
+
...ts.getDiagnosticsOptions(),
|
|
172
|
+
noSemanticValidation: true
|
|
173
|
+
});
|
|
174
|
+
ts.setCompilerOptions({
|
|
175
|
+
...ts.getCompilerOptions(),
|
|
176
|
+
jsx: monaco.languages.typescript.JsxEmit.Preserve
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function releaseDemoTypescriptDefaults(monaco) {
|
|
180
|
+
demoDefaultsUsers -= 1;
|
|
181
|
+
if (demoDefaultsUsers > 0 || !savedTypescriptDefaults) return;
|
|
182
|
+
const ts = monaco.languages.typescript.typescriptDefaults;
|
|
183
|
+
ts.setDiagnosticsOptions(savedTypescriptDefaults.diagnostics);
|
|
184
|
+
ts.setCompilerOptions(savedTypescriptDefaults.compiler);
|
|
185
|
+
savedTypescriptDefaults = null;
|
|
186
|
+
}
|
|
187
|
+
function LiveMonacoEditor({ themeConfig, height = '220px', value, onChange, onMount, language = "typescript", options = {} }) {
|
|
188
|
+
const extension = 'json' === language ? 'json' : 'tsx';
|
|
189
|
+
const modelPath = `file:///editor-${useId().replace(/[^a-zA-Z0-9]/g, '')}.${extension}`;
|
|
190
|
+
const monacoRef = useRef(null);
|
|
191
|
+
useEffect(()=>()=>{
|
|
192
|
+
if (monacoRef.current) releaseDemoTypescriptDefaults(monacoRef.current);
|
|
193
|
+
monacoRef.current = null;
|
|
194
|
+
}, []);
|
|
195
|
+
return /*#__PURE__*/ jsx(react, {
|
|
196
|
+
height: height,
|
|
197
|
+
path: modelPath,
|
|
198
|
+
defaultLanguage: language,
|
|
199
|
+
...onChange ? {
|
|
200
|
+
value: value ?? ''
|
|
201
|
+
} : {
|
|
202
|
+
defaultValue: value ?? monacoSample
|
|
203
|
+
},
|
|
204
|
+
theme: themeConfig.monacoThemeName,
|
|
205
|
+
beforeMount: (monaco)=>{
|
|
206
|
+
registerAllMonacoThemes(monaco);
|
|
207
|
+
if (!monacoRef.current) {
|
|
208
|
+
monacoRef.current = monaco;
|
|
209
|
+
acquireDemoTypescriptDefaults(monaco);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
onChange: onChange,
|
|
213
|
+
onMount: onMount,
|
|
214
|
+
options: {
|
|
215
|
+
fontSize: 13,
|
|
216
|
+
lineHeight: 20,
|
|
217
|
+
minimap: {
|
|
218
|
+
enabled: false
|
|
219
|
+
},
|
|
220
|
+
scrollBeyondLastLine: false,
|
|
221
|
+
wordWrap: 'on',
|
|
222
|
+
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
|
223
|
+
padding: {
|
|
224
|
+
top: 16,
|
|
225
|
+
bottom: 16
|
|
226
|
+
},
|
|
227
|
+
lineNumbers: 'on',
|
|
228
|
+
glyphMargin: false,
|
|
229
|
+
folding: false,
|
|
230
|
+
renderLineHighlight: 'line',
|
|
231
|
+
hideCursorInOverviewRuler: true,
|
|
232
|
+
overviewRulerBorder: false,
|
|
233
|
+
scrollbar: {
|
|
234
|
+
vertical: 'auto',
|
|
235
|
+
horizontal: 'hidden',
|
|
236
|
+
alwaysConsumeMouseWheel: false
|
|
237
|
+
},
|
|
238
|
+
automaticLayout: true,
|
|
239
|
+
fixedOverflowWidgets: true,
|
|
240
|
+
...options
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const futureDarkConfig = editorThemeConfigs[0];
|
|
245
|
+
function getStorybookThemeConfig() {
|
|
246
|
+
const keys = editorThemeConfigs.map((c)=>c.key);
|
|
247
|
+
const found = Array.from(document.body.classList).find((c)=>keys.includes(c));
|
|
248
|
+
return editorThemeConfigs.find((c)=>c.key === found) ?? futureDarkConfig;
|
|
249
|
+
}
|
|
250
|
+
function useEditorThemeConfig() {
|
|
251
|
+
const [themeConfig, setThemeConfig] = useState(getStorybookThemeConfig);
|
|
252
|
+
useEffect(()=>{
|
|
253
|
+
const observer = new MutationObserver(()=>setThemeConfig(getStorybookThemeConfig()));
|
|
254
|
+
observer.observe(document.body, {
|
|
255
|
+
attributes: true,
|
|
256
|
+
attributeFilter: [
|
|
257
|
+
'class'
|
|
258
|
+
]
|
|
259
|
+
});
|
|
260
|
+
return ()=>observer.disconnect();
|
|
261
|
+
}, []);
|
|
262
|
+
return themeConfig;
|
|
263
|
+
}
|
|
264
|
+
export { LiveMonacoEditor, editorThemeConfigs, monacoFullSample, monacoSample, registerAllMonacoThemes, useEditorThemeConfig };
|
|
@@ -32,18 +32,33 @@ const external_lucide_react_namespaceObject = require("lucide-react");
|
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
33
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
34
34
|
const external_command_cjs_namespaceObject = require("./command.cjs");
|
|
35
|
+
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
35
36
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
36
37
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
37
38
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
39
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
38
40
|
const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, items, value, onValueChange, placeholder = 'Select an option...', searchPlaceholder = 'Search...', emptyText = 'No results found.', disabled, className, error, errorId, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
39
41
|
const [open, setOpen] = external_react_namespaceObject.useState(false);
|
|
42
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
43
|
+
const grouped = group.inGroup;
|
|
40
44
|
const generatedId = external_react_namespaceObject.useId();
|
|
41
45
|
const validationId = errorId ?? `${id ?? `combobox-${generatedId.replace(/:/g, '')}`}-error`;
|
|
42
|
-
const describedBy = [
|
|
43
|
-
ariaDescribedBy,
|
|
44
|
-
error ? validationId : void 0
|
|
45
|
-
].filter(Boolean).join(' ');
|
|
46
46
|
const selectedItem = items.find((item)=>item.value === value);
|
|
47
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
48
|
+
error,
|
|
49
|
+
errorId: validationId,
|
|
50
|
+
'aria-invalid': ariaInvalid,
|
|
51
|
+
'aria-describedby': ariaDescribedBy,
|
|
52
|
+
'aria-errormessage': ariaErrorMessage
|
|
53
|
+
});
|
|
54
|
+
const triggerProps = {
|
|
55
|
+
id,
|
|
56
|
+
role: 'combobox',
|
|
57
|
+
'aria-expanded': open,
|
|
58
|
+
'aria-label': id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
59
|
+
...validation.aria,
|
|
60
|
+
disabled: disabled || group.disabled
|
|
61
|
+
};
|
|
47
62
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
48
63
|
children: [
|
|
49
64
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
@@ -51,20 +66,22 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
51
66
|
open: open,
|
|
52
67
|
onOpenChange: setOpen,
|
|
53
68
|
children: [
|
|
54
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
69
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
70
|
+
ref: ref,
|
|
71
|
+
...triggerProps,
|
|
72
|
+
className: className,
|
|
73
|
+
placeholder: placeholder,
|
|
74
|
+
children: selectedItem && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
75
|
+
className: "truncate",
|
|
76
|
+
children: selectedItem.label
|
|
77
|
+
})
|
|
78
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
55
79
|
asChild: true,
|
|
56
80
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
57
81
|
ref: ref,
|
|
58
|
-
id: id,
|
|
59
82
|
variant: "outline",
|
|
60
|
-
|
|
61
|
-
"aria-expanded": open,
|
|
62
|
-
"aria-label": id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
63
|
-
"aria-describedby": describedBy || void 0,
|
|
64
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
65
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
83
|
+
...triggerProps,
|
|
66
84
|
className: (0, index_cjs_namespaceObject.cn)('w-[280px] justify-between future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
67
|
-
disabled: disabled,
|
|
68
85
|
children: [
|
|
69
86
|
selectedItem ? selectedItem.label : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
70
87
|
className: "text-foreground-muted",
|
|
@@ -77,7 +94,8 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
77
94
|
})
|
|
78
95
|
}),
|
|
79
96
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
80
|
-
className:
|
|
97
|
+
className: (0, index_cjs_namespaceObject.cn)('p-0', grouped ? 'w-(--radix-popover-trigger-width)' : 'w-[280px]'),
|
|
98
|
+
align: grouped ? 'start' : void 0,
|
|
81
99
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.Command, {
|
|
82
100
|
children: [
|
|
83
101
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandInput, {
|
|
@@ -110,7 +128,7 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
110
128
|
})
|
|
111
129
|
]
|
|
112
130
|
}),
|
|
113
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
131
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
114
132
|
id: validationId,
|
|
115
133
|
children: error
|
|
116
134
|
})
|
|
@@ -4,18 +4,33 @@ import { Check, ChevronDown } from "lucide-react";
|
|
|
4
4
|
import { forwardRef, useId, useState } from "react";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
7
|
+
import { InputGroupPopoverTrigger } from "./input-group.js";
|
|
7
8
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
8
9
|
import { cn } from "../../lib/index.js";
|
|
9
10
|
import { FormFieldError } from "./form-field.js";
|
|
11
|
+
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
10
12
|
const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value, onValueChange, placeholder = 'Select an option...', searchPlaceholder = 'Search...', emptyText = 'No results found.', disabled, className, error, errorId, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
11
13
|
const [open, setOpen] = useState(false);
|
|
14
|
+
const group = useInputGroup();
|
|
15
|
+
const grouped = group.inGroup;
|
|
12
16
|
const generatedId = useId();
|
|
13
17
|
const validationId = errorId ?? `${id ?? `combobox-${generatedId.replace(/:/g, '')}`}-error`;
|
|
14
|
-
const describedBy = [
|
|
15
|
-
ariaDescribedBy,
|
|
16
|
-
error ? validationId : void 0
|
|
17
|
-
].filter(Boolean).join(' ');
|
|
18
18
|
const selectedItem = items.find((item)=>item.value === value);
|
|
19
|
+
const validation = useControlValidation(group, {
|
|
20
|
+
error,
|
|
21
|
+
errorId: validationId,
|
|
22
|
+
'aria-invalid': ariaInvalid,
|
|
23
|
+
'aria-describedby': ariaDescribedBy,
|
|
24
|
+
'aria-errormessage': ariaErrorMessage
|
|
25
|
+
});
|
|
26
|
+
const triggerProps = {
|
|
27
|
+
id,
|
|
28
|
+
role: 'combobox',
|
|
29
|
+
'aria-expanded': open,
|
|
30
|
+
'aria-label': id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
31
|
+
...validation.aria,
|
|
32
|
+
disabled: disabled || group.disabled
|
|
33
|
+
};
|
|
19
34
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
20
35
|
children: [
|
|
21
36
|
/*#__PURE__*/ jsxs(Popover, {
|
|
@@ -23,20 +38,22 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value,
|
|
|
23
38
|
open: open,
|
|
24
39
|
onOpenChange: setOpen,
|
|
25
40
|
children: [
|
|
26
|
-
/*#__PURE__*/ jsx(
|
|
41
|
+
grouped ? /*#__PURE__*/ jsx(InputGroupPopoverTrigger, {
|
|
42
|
+
ref: ref,
|
|
43
|
+
...triggerProps,
|
|
44
|
+
className: className,
|
|
45
|
+
placeholder: placeholder,
|
|
46
|
+
children: selectedItem && /*#__PURE__*/ jsx("span", {
|
|
47
|
+
className: "truncate",
|
|
48
|
+
children: selectedItem.label
|
|
49
|
+
})
|
|
50
|
+
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
27
51
|
asChild: true,
|
|
28
52
|
children: /*#__PURE__*/ jsxs(Button, {
|
|
29
53
|
ref: ref,
|
|
30
|
-
id: id,
|
|
31
54
|
variant: "outline",
|
|
32
|
-
|
|
33
|
-
"aria-expanded": open,
|
|
34
|
-
"aria-label": id ? void 0 : selectedItem ? selectedItem.label : placeholder,
|
|
35
|
-
"aria-describedby": describedBy || void 0,
|
|
36
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
37
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
55
|
+
...triggerProps,
|
|
38
56
|
className: cn('w-[280px] justify-between future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
39
|
-
disabled: disabled,
|
|
40
57
|
children: [
|
|
41
58
|
selectedItem ? selectedItem.label : /*#__PURE__*/ jsx("span", {
|
|
42
59
|
className: "text-foreground-muted",
|
|
@@ -49,7 +66,8 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value,
|
|
|
49
66
|
})
|
|
50
67
|
}),
|
|
51
68
|
/*#__PURE__*/ jsx(PopoverContent, {
|
|
52
|
-
className:
|
|
69
|
+
className: cn('p-0', grouped ? 'w-(--radix-popover-trigger-width)' : 'w-[280px]'),
|
|
70
|
+
align: grouped ? 'start' : void 0,
|
|
53
71
|
children: /*#__PURE__*/ jsxs(Command, {
|
|
54
72
|
children: [
|
|
55
73
|
/*#__PURE__*/ jsx(CommandInput, {
|
|
@@ -82,7 +100,7 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ id, items, value,
|
|
|
82
100
|
})
|
|
83
101
|
]
|
|
84
102
|
}),
|
|
85
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
103
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
86
104
|
id: validationId,
|
|
87
105
|
children: error
|
|
88
106
|
})
|
|
@@ -34,34 +34,51 @@ const external_lucide_react_namespaceObject = require("lucide-react");
|
|
|
34
34
|
const external_react_namespaceObject = require("react");
|
|
35
35
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
36
36
|
const external_calendar_cjs_namespaceObject = require("./calendar.cjs");
|
|
37
|
+
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
37
38
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
38
39
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
39
40
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
41
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
40
42
|
const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
41
43
|
const generatedId = external_react_namespaceObject.useId();
|
|
42
44
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
46
|
+
const grouped = group.inGroup;
|
|
47
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
48
|
+
error,
|
|
49
|
+
errorId: validationId,
|
|
50
|
+
'aria-invalid': ariaInvalid,
|
|
51
|
+
'aria-describedby': ariaDescribedBy,
|
|
52
|
+
'aria-errormessage': ariaErrorMessage
|
|
53
|
+
});
|
|
54
|
+
const triggerProps = {
|
|
55
|
+
id,
|
|
56
|
+
'aria-label': id || ariaLabelledBy ? void 0 : value ? `Selected date: ${(0, external_date_fns_namespaceObject.format)(value, 'PPP')}` : placeholder,
|
|
57
|
+
'aria-labelledby': ariaLabelledBy,
|
|
58
|
+
...validation.aria,
|
|
59
|
+
disabled: disabled || group.disabled
|
|
60
|
+
};
|
|
47
61
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
48
62
|
children: [
|
|
49
63
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
50
64
|
"data-slot": "date-picker",
|
|
51
65
|
children: [
|
|
52
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
66
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
67
|
+
ref: ref,
|
|
68
|
+
...triggerProps,
|
|
69
|
+
className: className,
|
|
70
|
+
placeholder: placeholder,
|
|
71
|
+
children: value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
72
|
+
className: "truncate",
|
|
73
|
+
children: (0, external_date_fns_namespaceObject.format)(value, 'PPP')
|
|
74
|
+
})
|
|
75
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
53
76
|
asChild: true,
|
|
54
77
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
78
|
+
...triggerProps,
|
|
55
79
|
ref: ref,
|
|
56
|
-
id: id,
|
|
57
80
|
variant: "outline",
|
|
58
|
-
"aria-label": id || ariaLabelledBy ? void 0 : value ? `Selected date: ${(0, external_date_fns_namespaceObject.format)(value, 'PPP')}` : placeholder,
|
|
59
|
-
"aria-labelledby": ariaLabelledBy,
|
|
60
|
-
"aria-describedby": describedBy || void 0,
|
|
61
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
62
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
63
81
|
className: (0, index_cjs_namespaceObject.cn)('w-full justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
64
|
-
disabled: disabled,
|
|
65
82
|
children: [
|
|
66
83
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
67
84
|
value ? (0, external_date_fns_namespaceObject.format)(value, 'PPP') : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
@@ -73,6 +90,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
73
90
|
}),
|
|
74
91
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
75
92
|
className: "w-auto p-0",
|
|
93
|
+
align: grouped ? 'start' : void 0,
|
|
76
94
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
77
95
|
mode: "single",
|
|
78
96
|
selected: value,
|
|
@@ -83,7 +101,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
83
101
|
})
|
|
84
102
|
]
|
|
85
103
|
}),
|
|
86
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
104
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
87
105
|
id: validationId,
|
|
88
106
|
children: error
|
|
89
107
|
})
|
|
@@ -93,29 +111,47 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
93
111
|
const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date range', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
94
112
|
const generatedId = external_react_namespaceObject.useId();
|
|
95
113
|
const validationId = errorId ?? `${id ?? `date-range-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
96
|
-
const describedBy = [
|
|
97
|
-
ariaDescribedBy,
|
|
98
|
-
error ? validationId : void 0
|
|
99
|
-
].filter(Boolean).join(' ');
|
|
100
114
|
const computedLabel = value?.from ? value.to ? `Selected range: ${(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y')} to ${(0, external_date_fns_namespaceObject.format)(value.to, 'LLL dd, y')}` : `Selected date: ${(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y')}` : placeholder;
|
|
115
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
116
|
+
const grouped = group.inGroup;
|
|
117
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
118
|
+
error,
|
|
119
|
+
errorId: validationId,
|
|
120
|
+
'aria-invalid': ariaInvalid,
|
|
121
|
+
'aria-describedby': ariaDescribedBy,
|
|
122
|
+
'aria-errormessage': ariaErrorMessage
|
|
123
|
+
});
|
|
124
|
+
const triggerProps = {
|
|
125
|
+
id,
|
|
126
|
+
'aria-label': id || ariaLabelledBy ? void 0 : computedLabel,
|
|
127
|
+
'aria-labelledby': ariaLabelledBy,
|
|
128
|
+
...validation.aria,
|
|
129
|
+
disabled: disabled || group.disabled
|
|
130
|
+
};
|
|
101
131
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
102
132
|
children: [
|
|
103
133
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
104
134
|
"data-slot": "date-range-picker",
|
|
105
135
|
children: [
|
|
106
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
136
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupPopoverTrigger, {
|
|
137
|
+
ref: ref,
|
|
138
|
+
...triggerProps,
|
|
139
|
+
className: className,
|
|
140
|
+
placeholder: placeholder,
|
|
141
|
+
children: value?.from && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
142
|
+
className: "truncate",
|
|
143
|
+
children: [
|
|
144
|
+
(0, external_date_fns_namespaceObject.format)(value.from, 'LLL dd, y'),
|
|
145
|
+
value.to && ` - ${(0, external_date_fns_namespaceObject.format)(value.to, 'LLL dd, y')}`
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
107
149
|
asChild: true,
|
|
108
150
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
151
|
+
...triggerProps,
|
|
109
152
|
ref: ref,
|
|
110
|
-
id: id,
|
|
111
153
|
variant: "outline",
|
|
112
|
-
"aria-label": id || ariaLabelledBy ? void 0 : computedLabel,
|
|
113
|
-
"aria-labelledby": ariaLabelledBy,
|
|
114
|
-
"aria-describedby": describedBy || void 0,
|
|
115
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
116
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
117
154
|
className: (0, index_cjs_namespaceObject.cn)('w-[300px] justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
118
|
-
disabled: disabled,
|
|
119
155
|
children: [
|
|
120
156
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
121
157
|
value?.from ? value.to ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
@@ -147,7 +183,7 @@ const date_picker_DateRangePicker = /*#__PURE__*/ external_react_namespaceObject
|
|
|
147
183
|
})
|
|
148
184
|
]
|
|
149
185
|
}),
|
|
150
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
186
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
151
187
|
id: validationId,
|
|
152
188
|
children: error
|
|
153
189
|
})
|