@povio/ui 3.0.0-rc.1 → 3.0.0-rc.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.
@@ -161,6 +161,8 @@ var DatePickerBase = (props) => {
161
161
  };
162
162
  const onInputClear = () => {
163
163
  onChange?.(null);
164
+ dialogState.setValue(null);
165
+ if (fireBlurOnChange) handleBlur(null);
164
166
  };
165
167
  useEffect(() => {
166
168
  if (!state.isOpen) return;
@@ -431,6 +431,16 @@ var DateRangePickerBase = (props) => {
431
431
  };
432
432
  const onInputClear = () => {
433
433
  onChange?.(null);
434
+ dialogState.setValue(null);
435
+ leftCalendarState.setValue(null);
436
+ rightCalendarState.setValue(null);
437
+ setRangeSelection({
438
+ start: null,
439
+ end: null,
440
+ isSelecting: false
441
+ });
442
+ setHoverDate(null);
443
+ if (fireBlurOnChange) handleBlur(null);
434
444
  };
435
445
  const onOpenChange = (isOpen) => {
436
446
  state.toggle();
@@ -152,6 +152,11 @@ var DateTimePickerBase = (props) => {
152
152
  dialogState.setValue(currentValue);
153
153
  calendarState.setFocusedDate(toCalendarDate(currentValue));
154
154
  };
155
+ const onInputClear = () => {
156
+ onChange?.(null);
157
+ dialogState.setValue(null);
158
+ if (fireBlurOnChange) handleBlur(null);
159
+ };
155
160
  const onOpenChange = (isOpen) => {
156
161
  state.toggle();
157
162
  calendarState.setFocusedDate(state.value || today(effectiveTimeZone));
@@ -219,7 +224,8 @@ var DateTimePickerBase = (props) => {
219
224
  timeZone: effectiveTimeZone,
220
225
  isTimeOptional,
221
226
  format,
222
- fireBlurOnChange
227
+ fireBlurOnChange,
228
+ onClear: onInputClear
223
229
  }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
224
230
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
225
231
  isDisabled,
@@ -41,5 +41,5 @@ interface DatePickerInputProps extends InputVariantProps {
41
41
  fireBlurOnChange?: boolean;
42
42
  onClear?: () => void;
43
43
  }
44
- export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, fieldValue, endFieldValue, isValueControlled, hasValue, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize, todayIconButtonComponent, todayIconPlacement, isDirty, isRequired, disableManualEntry, autoFixYear, placeholder, className, onOpenDropdown, dateGranularity, timeZone, isTimeOptional, format, fireBlurOnChange, onClear: onClearProp, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
44
+ export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, fieldValue, endFieldValue, isValueControlled, hasValue, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize, todayIconButtonComponent, todayIconPlacement, isDirty, isRequired, disableManualEntry, autoFixYear, placeholder, className, onOpenDropdown, dateGranularity, timeZone: timeZoneProp, isTimeOptional, format, fireBlurOnChange, onClear: onClearProp, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
45
45
  export {};
@@ -15,18 +15,20 @@ import { clsx } from "clsx";
15
15
  import { useImperativeHandle, useRef, useState } from "react";
16
16
  import { Button } from "react-aria-components";
17
17
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
18
- import { today } from "@internationalized/date";
18
+ import { getLocalTimeZone, today } from "@internationalized/date";
19
19
  //#region src/components/inputs/DateTime/shared/DatePickerInput.tsx
20
20
  var DatePickerInput = (t0) => {
21
- const $ = c(108);
22
- const { ref, as, groupProps, fieldProps, endFieldProps, fieldValue, endFieldValue, isValueControlled, hasValue, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize: t1, todayIconButtonComponent, todayIconPlacement: t2, isDirty, isRequired, disableManualEntry, autoFixYear: t3, placeholder, className, onOpenDropdown, dateGranularity: t4, timeZone, isTimeOptional: t5, format, fireBlurOnChange, onClear: onClearProp, ...props } = t0;
21
+ const $ = c(95);
22
+ const { ref, as, groupProps, fieldProps, endFieldProps, fieldValue, endFieldValue, isValueControlled, hasValue, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize: t1, todayIconButtonComponent, todayIconPlacement: t2, isDirty, isRequired, disableManualEntry, autoFixYear: t3, placeholder, className, onOpenDropdown, dateGranularity: t4, timeZone: timeZoneProp, isTimeOptional: t5, format, fireBlurOnChange, onClear: onClearProp, ...props } = t0;
23
23
  const todayIconButtonSize = t1 === void 0 ? "none" : t1;
24
24
  const todayIconPlacement = t2 === void 0 ? "content" : t2;
25
25
  const autoFixYear = t3 === void 0 ? false : t3;
26
26
  const dateGranularity = t4 === void 0 ? "day" : t4;
27
27
  const isTimeOptional = t5 === void 0 ? false : t5;
28
28
  const uiConfig = UIConfig.useConfig();
29
- const effectiveTimeZone = timeZone ?? "UTC";
29
+ const timeZone = timeZoneProp ?? uiConfig.dateInput.timeZone;
30
+ let effectiveTimeZone = getLocalTimeZone();
31
+ if (timeZone !== "clientLocal") effectiveTimeZone = timeZone;
30
32
  const inputBaseCva = UIOverrides.useCva("input.baseCva", inputBaseDefinition);
31
33
  const inputSizeCva = UIOverrides.useCva("input.sizeCva", inputSizeDefinition);
32
34
  const datePickerInputContentRowCva = UIOverrides.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
@@ -129,112 +131,91 @@ var DatePickerInput = (t0) => {
129
131
  const onClearChange = t14;
130
132
  const showClear = canClear || hasValue || normalizedFieldProps.value != null || normalizedEndFieldProps?.value != null;
131
133
  const isTodayIconDisabled = isDisabled || buttonProps.isDisabled;
132
- let t15;
133
- if ($[20] !== effectiveTimeZone || $[21] !== endFieldProps || $[22] !== fieldProps || $[23] !== fireBlurOnChange || $[24] !== isDateTime || $[25] !== isTodayIconDisabled) {
134
- t15 = () => {
135
- if (isTodayIconDisabled) return;
136
- if (isDateTime) {
137
- const calendarDateTime = DateTimeUtils.getCurrentWallClockCalendarDateTime();
138
- fieldProps.onChange?.(calendarDateTime);
139
- if (endFieldProps) endFieldProps.onChange?.(calendarDateTime);
140
- } else {
141
- fieldProps.onChange?.(today(effectiveTimeZone));
142
- if (endFieldProps) endFieldProps.onChange?.(today(effectiveTimeZone));
143
- }
144
- if (fireBlurOnChange) {
145
- fieldProps.onBlur?.(null);
146
- endFieldProps?.onBlur?.(null);
147
- }
148
- };
149
- $[20] = effectiveTimeZone;
150
- $[21] = endFieldProps;
151
- $[22] = fieldProps;
152
- $[23] = fireBlurOnChange;
153
- $[24] = isDateTime;
154
- $[25] = isTodayIconDisabled;
155
- $[26] = t15;
156
- } else t15 = $[26];
157
- const onToday = t15;
134
+ const onToday = () => {
135
+ if (isTodayIconDisabled) return;
136
+ if (isDateTime) {
137
+ const calendarDateTime = DateTimeUtils.getCurrentWallClockCalendarDateTime();
138
+ fieldProps.onChange?.(calendarDateTime);
139
+ if (endFieldProps) endFieldProps.onChange?.(calendarDateTime);
140
+ } else {
141
+ fieldProps.onChange?.(today(effectiveTimeZone));
142
+ if (endFieldProps) endFieldProps.onChange?.(today(effectiveTimeZone));
143
+ }
144
+ if (fireBlurOnChange) {
145
+ fieldProps.onBlur?.(null);
146
+ endFieldProps?.onBlur?.(null);
147
+ }
148
+ };
158
149
  const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
159
- let t16;
160
- if ($[27] !== isTodayIconDisabled || $[28] !== onToday || $[29] !== todayIcon || $[30] !== todayIconButtonComponent || $[31] !== todayIconButtonSize) {
161
- t16 = renderDatePickerTodayIcon(todayIcon, {
162
- isDisabled: isTodayIconDisabled,
163
- onPress: onToday,
164
- size: todayIconButtonSize,
165
- todayIconButtonComponent
166
- });
167
- $[27] = isTodayIconDisabled;
168
- $[28] = onToday;
169
- $[29] = todayIcon;
170
- $[30] = todayIconButtonComponent;
171
- $[31] = todayIconButtonSize;
172
- $[32] = t16;
173
- } else t16 = $[32];
174
- const todayIconButton = t16;
150
+ const todayIconButton = renderDatePickerTodayIcon(todayIcon, {
151
+ isDisabled: isTodayIconDisabled,
152
+ onPress: onToday,
153
+ size: todayIconButtonSize,
154
+ todayIconButtonComponent
155
+ });
175
156
  const shouldRenderTodayIconWithFieldLabel = todayIconPlacement === "fieldLabel";
176
157
  const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
177
- const t17 = clsx("group group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", groupProps.className, inputBaseCva({
158
+ const t15 = clsx("group group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", groupProps.className, inputBaseCva({
178
159
  variant,
179
160
  as,
180
161
  ...props
181
162
  }), className);
182
- const t18 = isHovered || void 0;
183
- const t19 = isDisabled || void 0;
184
- const t20 = isDisabled || void 0;
185
- const t21 = isInvalid || void 0;
186
- const t22 = normalizedFieldProps.value == null || void 0;
187
- const t23 = isFocused || void 0;
188
- const t24 = isFocused && isFocusVisible || void 0;
189
- const t25 = normalizedFieldProps.value != null || void 0;
190
- const t26 = isDirty || void 0;
191
- const t27 = isRequired || void 0;
192
- const t28 = normalizedFieldProps.value != null || void 0;
193
- let t29;
194
- if ($[33] !== as || $[34] !== inputSizeCva || $[35] !== size) {
195
- t29 = clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
163
+ const t16 = isHovered || void 0;
164
+ const t17 = isDisabled || void 0;
165
+ const t18 = isDisabled || void 0;
166
+ const t19 = isInvalid || void 0;
167
+ const t20 = normalizedFieldProps.value == null || void 0;
168
+ const t21 = isFocused || void 0;
169
+ const t22 = isFocused && isFocusVisible || void 0;
170
+ const t23 = normalizedFieldProps.value != null || void 0;
171
+ const t24 = isDirty || void 0;
172
+ const t25 = isRequired || void 0;
173
+ const t26 = normalizedFieldProps.value != null || void 0;
174
+ let t27;
175
+ if ($[20] !== as || $[21] !== inputSizeCva || $[22] !== size) {
176
+ t27 = clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
196
177
  size,
197
178
  as
198
179
  }));
199
- $[33] = as;
200
- $[34] = inputSizeCva;
201
- $[35] = size;
202
- $[36] = t29;
203
- } else t29 = $[36];
204
- let t30;
205
- if ($[37] !== as || $[38] !== headerProps) {
206
- t30 = as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
180
+ $[20] = as;
181
+ $[21] = inputSizeCva;
182
+ $[22] = size;
183
+ $[23] = t27;
184
+ } else t27 = $[23];
185
+ let t28;
186
+ if ($[24] !== as || $[25] !== headerProps) {
187
+ t28 = as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
207
188
  as,
208
189
  ...headerProps
209
190
  });
210
- $[37] = as;
211
- $[38] = headerProps;
212
- $[39] = t30;
213
- } else t30 = $[39];
214
- const t31 = shouldRenderTodayIconWithFieldLabel && todayIconButton;
215
- let t32;
216
- if ($[40] !== datePickerInputContentRowCva || $[41] !== size) {
217
- t32 = datePickerInputContentRowCva({ size });
218
- $[40] = datePickerInputContentRowCva;
219
- $[41] = size;
220
- $[42] = t32;
221
- } else t32 = $[42];
222
- let t33;
223
- if ($[43] !== disableManualEntry || $[44] !== isDisabled || $[45] !== onOpenDropdown) {
224
- t33 = disableManualEntry && /* @__PURE__ */ jsx(Button, {
191
+ $[24] = as;
192
+ $[25] = headerProps;
193
+ $[26] = t28;
194
+ } else t28 = $[26];
195
+ const t29 = shouldRenderTodayIconWithFieldLabel && todayIconButton;
196
+ let t30;
197
+ if ($[27] !== datePickerInputContentRowCva || $[28] !== size) {
198
+ t30 = datePickerInputContentRowCva({ size });
199
+ $[27] = datePickerInputContentRowCva;
200
+ $[28] = size;
201
+ $[29] = t30;
202
+ } else t30 = $[29];
203
+ let t31;
204
+ if ($[30] !== disableManualEntry || $[31] !== isDisabled || $[32] !== onOpenDropdown) {
205
+ t31 = disableManualEntry && /* @__PURE__ */ jsx(Button, {
225
206
  onPress: onOpenDropdown,
226
207
  className: "absolute inset-0 z-0",
227
208
  isDisabled
228
209
  });
229
- $[43] = disableManualEntry;
230
- $[44] = isDisabled;
231
- $[45] = onOpenDropdown;
232
- $[46] = t33;
233
- } else t33 = $[46];
234
- const t34 = !shouldRenderTodayIconWithFieldLabel && todayIconButton;
235
- let t35;
236
- if ($[47] !== as || $[48] !== dateGranularity || $[49] !== disableManualEntry || $[50] !== effectiveTimeZone || $[51] !== fieldProps || $[52] !== format || $[53] !== hidePlaceholder || $[54] !== isDisabled || $[55] !== isInvalid || $[56] !== isTimeOptional || $[57] !== normalizedEndFieldProps || $[58] !== normalizedFieldProps || $[59] !== onClearChange || $[60] !== placeholder) {
237
- t35 = disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
210
+ $[30] = disableManualEntry;
211
+ $[31] = isDisabled;
212
+ $[32] = onOpenDropdown;
213
+ $[33] = t31;
214
+ } else t31 = $[33];
215
+ const t32 = !shouldRenderTodayIconWithFieldLabel && todayIconButton;
216
+ let t33;
217
+ if ($[34] !== as || $[35] !== dateGranularity || $[36] !== disableManualEntry || $[37] !== effectiveTimeZone || $[38] !== fieldProps || $[39] !== format || $[40] !== hidePlaceholder || $[41] !== isDisabled || $[42] !== isInvalid || $[43] !== isTimeOptional || $[44] !== normalizedEndFieldProps || $[45] !== normalizedFieldProps || $[46] !== onClearChange || $[47] !== placeholder) {
218
+ t33 = disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
238
219
  size: "label-1",
239
220
  className: "text-text-default-3",
240
221
  children: placeholder
@@ -265,79 +246,79 @@ var DatePickerInput = (t0) => {
265
246
  format,
266
247
  timeZone: effectiveTimeZone
267
248
  })] })] });
268
- $[47] = as;
269
- $[48] = dateGranularity;
270
- $[49] = disableManualEntry;
271
- $[50] = effectiveTimeZone;
272
- $[51] = fieldProps;
273
- $[52] = format;
274
- $[53] = hidePlaceholder;
275
- $[54] = isDisabled;
276
- $[55] = isInvalid;
277
- $[56] = isTimeOptional;
278
- $[57] = normalizedEndFieldProps;
279
- $[58] = normalizedFieldProps;
280
- $[59] = onClearChange;
281
- $[60] = placeholder;
282
- $[61] = t35;
283
- } else t35 = $[61];
284
- let t36;
285
- if ($[62] !== t32 || $[63] !== t33 || $[64] !== t34 || $[65] !== t35) {
286
- t36 = /* @__PURE__ */ jsxs("div", {
287
- className: t32,
249
+ $[34] = as;
250
+ $[35] = dateGranularity;
251
+ $[36] = disableManualEntry;
252
+ $[37] = effectiveTimeZone;
253
+ $[38] = fieldProps;
254
+ $[39] = format;
255
+ $[40] = hidePlaceholder;
256
+ $[41] = isDisabled;
257
+ $[42] = isInvalid;
258
+ $[43] = isTimeOptional;
259
+ $[44] = normalizedEndFieldProps;
260
+ $[45] = normalizedFieldProps;
261
+ $[46] = onClearChange;
262
+ $[47] = placeholder;
263
+ $[48] = t33;
264
+ } else t33 = $[48];
265
+ let t34;
266
+ if ($[49] !== t30 || $[50] !== t31 || $[51] !== t32 || $[52] !== t33) {
267
+ t34 = /* @__PURE__ */ jsxs("div", {
268
+ className: t30,
288
269
  children: [
289
- t33,
290
- t34,
291
- t35
270
+ t31,
271
+ t32,
272
+ t33
292
273
  ]
293
274
  });
294
- $[62] = t32;
295
- $[63] = t33;
296
- $[64] = t34;
297
- $[65] = t35;
298
- $[66] = t36;
299
- } else t36 = $[66];
300
- let t37;
301
- if ($[67] !== t29 || $[68] !== t30 || $[69] !== t31 || $[70] !== t36) {
302
- t37 = /* @__PURE__ */ jsxs("div", {
303
- className: t29,
275
+ $[49] = t30;
276
+ $[50] = t31;
277
+ $[51] = t32;
278
+ $[52] = t33;
279
+ $[53] = t34;
280
+ } else t34 = $[53];
281
+ let t35;
282
+ if ($[54] !== t27 || $[55] !== t28 || $[56] !== t29 || $[57] !== t34) {
283
+ t35 = /* @__PURE__ */ jsxs("div", {
284
+ className: t27,
304
285
  children: [
305
- t30,
306
- t31,
307
- t36
286
+ t28,
287
+ t29,
288
+ t34
308
289
  ]
309
290
  });
310
- $[67] = t29;
311
- $[68] = t30;
312
- $[69] = t31;
313
- $[70] = t36;
314
- $[71] = t37;
315
- } else t37 = $[71];
316
- let t38;
317
- if ($[72] !== as || $[73] !== inputSizeCva || $[74] !== size) {
318
- t38 = clsx(inputSizeCva({
291
+ $[54] = t27;
292
+ $[55] = t28;
293
+ $[56] = t29;
294
+ $[57] = t34;
295
+ $[58] = t35;
296
+ } else t35 = $[58];
297
+ let t36;
298
+ if ($[59] !== as || $[60] !== inputSizeCva || $[61] !== size) {
299
+ t36 = clsx(inputSizeCva({
319
300
  size,
320
301
  as
321
302
  }), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!");
322
- $[72] = as;
323
- $[73] = inputSizeCva;
324
- $[74] = size;
325
- $[75] = t38;
326
- } else t38 = $[75];
327
- let t39;
328
- if ($[76] !== clearInput || $[77] !== isClearable || $[78] !== showClear) {
329
- t39 = isClearable && /* @__PURE__ */ jsx(InputClear, {
303
+ $[59] = as;
304
+ $[60] = inputSizeCva;
305
+ $[61] = size;
306
+ $[62] = t36;
307
+ } else t36 = $[62];
308
+ let t37;
309
+ if ($[63] !== clearInput || $[64] !== isClearable || $[65] !== showClear) {
310
+ t37 = isClearable && /* @__PURE__ */ jsx(InputClear, {
330
311
  onClear: clearInput,
331
312
  show: showClear
332
313
  });
333
- $[76] = clearInput;
334
- $[77] = isClearable;
335
- $[78] = showClear;
336
- $[79] = t39;
337
- } else t39 = $[79];
338
- let t40;
339
- if ($[80] !== buttonProps || $[81] !== disableDropdown || $[82] !== disableManualEntry || $[83] !== isDisabled || $[84] !== pickerIcon) {
340
- t40 = (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
314
+ $[63] = clearInput;
315
+ $[64] = isClearable;
316
+ $[65] = showClear;
317
+ $[66] = t37;
318
+ } else t37 = $[66];
319
+ let t38;
320
+ if ($[67] !== buttonProps || $[68] !== disableDropdown || $[69] !== disableManualEntry || $[70] !== isDisabled || $[71] !== pickerIcon) {
321
+ t38 = (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
341
322
  label: "",
342
323
  color: "secondary",
343
324
  ...buttonProps,
@@ -345,67 +326,67 @@ var DatePickerInput = (t0) => {
345
326
  isDisabled,
346
327
  className: "border-0!"
347
328
  });
348
- $[80] = buttonProps;
349
- $[81] = disableDropdown;
350
- $[82] = disableManualEntry;
351
- $[83] = isDisabled;
352
- $[84] = pickerIcon;
353
- $[85] = t40;
354
- } else t40 = $[85];
355
- let t41;
356
- if ($[86] !== t38 || $[87] !== t39 || $[88] !== t40) {
357
- t41 = /* @__PURE__ */ jsxs("div", {
358
- className: t38,
359
- children: [t39, t40]
329
+ $[67] = buttonProps;
330
+ $[68] = disableDropdown;
331
+ $[69] = disableManualEntry;
332
+ $[70] = isDisabled;
333
+ $[71] = pickerIcon;
334
+ $[72] = t38;
335
+ } else t38 = $[72];
336
+ let t39;
337
+ if ($[73] !== t36 || $[74] !== t37 || $[75] !== t38) {
338
+ t39 = /* @__PURE__ */ jsxs("div", {
339
+ className: t36,
340
+ children: [t37, t38]
360
341
  });
361
- $[86] = t38;
362
- $[87] = t39;
363
- $[88] = t40;
364
- $[89] = t41;
365
- } else t41 = $[89];
366
- let t42;
367
- if ($[90] !== focusWithinProps || $[91] !== groupProps || $[92] !== hoverProps || $[93] !== t17 || $[94] !== t18 || $[95] !== t19 || $[96] !== t20 || $[97] !== t21 || $[98] !== t22 || $[99] !== t23 || $[100] !== t24 || $[101] !== t25 || $[102] !== t26 || $[103] !== t27 || $[104] !== t28 || $[105] !== t37 || $[106] !== t41) {
368
- t42 = /* @__PURE__ */ jsxs("div", {
342
+ $[73] = t36;
343
+ $[74] = t37;
344
+ $[75] = t38;
345
+ $[76] = t39;
346
+ } else t39 = $[76];
347
+ let t40;
348
+ if ($[77] !== focusWithinProps || $[78] !== groupProps || $[79] !== hoverProps || $[80] !== t15 || $[81] !== t16 || $[82] !== t17 || $[83] !== t18 || $[84] !== t19 || $[85] !== t20 || $[86] !== t21 || $[87] !== t22 || $[88] !== t23 || $[89] !== t24 || $[90] !== t25 || $[91] !== t26 || $[92] !== t35 || $[93] !== t39) {
349
+ t40 = /* @__PURE__ */ jsxs("div", {
369
350
  ref: containerRef,
370
351
  ...groupProps,
371
352
  ...focusWithinProps,
372
353
  ...hoverProps,
373
- className: t17,
354
+ className: t15,
374
355
  "data-rac": "",
375
356
  "data-datetime-input": "",
376
- "data-hovered": t18,
377
- "data-disabled": t19,
378
- "data-is-disabled": t20,
379
- "data-invalid": t21,
380
- "data-is-empty": t22,
381
- "data-focus-within": t23,
382
- "data-focus-visible": t24,
383
- "data-has-selection": t25,
384
- "data-is-dirty": t26,
385
- "data-is-required": t27,
386
- "data-is-filled": t28,
387
- children: [t37, t41]
357
+ "data-hovered": t16,
358
+ "data-disabled": t17,
359
+ "data-is-disabled": t18,
360
+ "data-invalid": t19,
361
+ "data-is-empty": t20,
362
+ "data-focus-within": t21,
363
+ "data-focus-visible": t22,
364
+ "data-has-selection": t23,
365
+ "data-is-dirty": t24,
366
+ "data-is-required": t25,
367
+ "data-is-filled": t26,
368
+ children: [t35, t39]
388
369
  });
389
- $[90] = focusWithinProps;
390
- $[91] = groupProps;
391
- $[92] = hoverProps;
392
- $[93] = t17;
393
- $[94] = t18;
394
- $[95] = t19;
395
- $[96] = t20;
396
- $[97] = t21;
397
- $[98] = t22;
398
- $[99] = t23;
399
- $[100] = t24;
400
- $[101] = t25;
401
- $[102] = t26;
402
- $[103] = t27;
403
- $[104] = t28;
404
- $[105] = t37;
405
- $[106] = t41;
406
- $[107] = t42;
407
- } else t42 = $[107];
408
- return t42;
370
+ $[77] = focusWithinProps;
371
+ $[78] = groupProps;
372
+ $[79] = hoverProps;
373
+ $[80] = t15;
374
+ $[81] = t16;
375
+ $[82] = t17;
376
+ $[83] = t18;
377
+ $[84] = t19;
378
+ $[85] = t20;
379
+ $[86] = t21;
380
+ $[87] = t22;
381
+ $[88] = t23;
382
+ $[89] = t24;
383
+ $[90] = t25;
384
+ $[91] = t26;
385
+ $[92] = t35;
386
+ $[93] = t39;
387
+ $[94] = t40;
388
+ } else t40 = $[94];
389
+ return t40;
409
390
  };
410
391
  //#endregion
411
392
  export { DatePickerInput };
@@ -1,6 +1,6 @@
1
1
  import { UIConfig } from "../../../../config/uiConfig.context.js";
2
2
  import { Autocomplete } from "./Autocomplete.js";
3
- import { getQueryItems, shouldEnableQueryForSelection } from "../shared/querySelect.utils.js";
3
+ import { getQueryItems, getSelectionIdsToResolve } from "../shared/querySelect.utils.js";
4
4
  import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
5
5
  import { c } from "react/compiler-runtime";
6
6
  import { jsx } from "react/jsx-runtime";
@@ -13,25 +13,28 @@ var QueryAutocompleteContent = ({ query, queryParams, queryOptions, queryMap, le
13
13
  const ui = UIConfig.useConfig();
14
14
  const [search, setSearch] = useState("");
15
15
  const { onChange, ...restProps } = props;
16
+ const value = "value" in props ? props.value : void 0;
17
+ const selectedIdsToResolve = getSelectionIdsToResolve({
18
+ initialSelection: props.initialSelection,
19
+ value,
20
+ mapInitialToSelectItem: props.mapInitialToSelectItem
21
+ });
16
22
  const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
17
23
  query,
18
24
  queryParams,
19
25
  queryOptions,
20
26
  mapItems: (data) => getQueryItems(data, queryMap),
21
27
  search,
22
- initialQueryState: shouldEnableQueryForSelection({
23
- initialSelection: props.initialSelection,
24
- value: "value" in props ? props.value : void 0,
25
- mapInitialToSelectItem: props.mapInitialToSelectItem
26
- }) ? false : props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled
28
+ initialQueryState: selectedIdsToResolve.count > 0 ? false : props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled,
29
+ selectedIdsToResolve: selectedIdsToResolve.items
27
30
  });
28
- const handleChange = (value) => {
29
- onChange?.(value);
31
+ const handleChange = (value_0) => {
32
+ onChange?.(value_0);
30
33
  props.onBlur?.({ target: { value: null } });
31
34
  };
32
35
  const { isInitialQueryDisabled: _, ...autocompleteProps } = restProps;
33
- const onSearchChange = (value_0) => {
34
- setSearch(value_0);
36
+ const onSearchChange = (value_1) => {
37
+ setSearch(value_1);
35
38
  handleEnableQuery();
36
39
  };
37
40
  return /* @__PURE__ */ jsx(Autocomplete, {
@@ -33,4 +33,5 @@ export interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey exte
33
33
  mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
34
34
  initialQueryState?: boolean;
35
35
  search?: string;
36
+ selectedIdsToResolve?: TKey[];
36
37
  }
@@ -1,6 +1,6 @@
1
1
  import { UIConfig } from "../../../../config/uiConfig.context.js";
2
2
  import { Select } from "./Select.js";
3
- import { getQueryItems, shouldEnableQueryForSelection } from "../shared/querySelect.utils.js";
3
+ import { getQueryItems, getSelectionIdsToResolve } from "../shared/querySelect.utils.js";
4
4
  import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
5
5
  import { c } from "react/compiler-runtime";
6
6
  import { jsx } from "react/jsx-runtime";
@@ -9,11 +9,18 @@ import { mergeRefs } from "@react-aria/utils";
9
9
  import { Controller } from "react-hook-form";
10
10
  //#region src/components/inputs/Selection/Select/QuerySelect.tsx
11
11
  var QuerySelectContent = (t0) => {
12
- const $ = c(28);
12
+ const $ = c(29);
13
13
  const { query, queryParams, queryOptions, queryMap, ...props } = t0;
14
14
  const ui = UIConfig.useConfig();
15
15
  const [search, setSearch] = useState("");
16
16
  const isSearchable = props.isSearchable ?? ui.select.isSearchable;
17
+ const value = "value" in props ? props.value : void 0;
18
+ const selectedIdsToResolve = getSelectionIdsToResolve({
19
+ initialSelection: props.initialSelection,
20
+ value,
21
+ mapInitialToSelectItem: props.mapInitialToSelectItem
22
+ });
23
+ const shouldEnableInitialQuery = selectedIdsToResolve.count > 0;
17
24
  let t1;
18
25
  if ($[0] !== queryMap) {
19
26
  t1 = (data) => getQueryItems(data, queryMap);
@@ -21,68 +28,66 @@ var QuerySelectContent = (t0) => {
21
28
  $[1] = t1;
22
29
  } else t1 = $[1];
23
30
  const t2 = isSearchable ? search : void 0;
24
- const t3 = shouldEnableQueryForSelection({
25
- initialSelection: props.initialSelection,
26
- value: "value" in props ? props.value : void 0,
27
- mapInitialToSelectItem: props.mapInitialToSelectItem
28
- }) ? false : props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled;
31
+ const t3 = shouldEnableInitialQuery ? false : props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled;
29
32
  let t4;
30
- if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== t1 || $[6] !== t2 || $[7] !== t3) {
33
+ if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== selectedIdsToResolve.items || $[6] !== t1 || $[7] !== t2 || $[8] !== t3) {
31
34
  t4 = {
32
35
  query,
33
36
  queryParams,
34
37
  queryOptions,
35
38
  mapItems: t1,
36
39
  search: t2,
37
- initialQueryState: t3
40
+ initialQueryState: t3,
41
+ selectedIdsToResolve: selectedIdsToResolve.items
38
42
  };
39
43
  $[2] = query;
40
44
  $[3] = queryOptions;
41
45
  $[4] = queryParams;
42
- $[5] = t1;
43
- $[6] = t2;
44
- $[7] = t3;
45
- $[8] = t4;
46
- } else t4 = $[8];
46
+ $[5] = selectedIdsToResolve.items;
47
+ $[6] = t1;
48
+ $[7] = t2;
49
+ $[8] = t3;
50
+ $[9] = t4;
51
+ } else t4 = $[9];
47
52
  const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete(t4);
48
53
  let onSearchChange;
49
54
  let selectProps;
50
- if ($[9] !== props) {
55
+ if ($[10] !== props) {
51
56
  const { isInitialQueryDisabled: _, onSearchChange: t5, ...t6 } = props;
52
57
  onSearchChange = t5;
53
58
  selectProps = t6;
54
- $[9] = props;
55
- $[10] = onSearchChange;
56
- $[11] = selectProps;
59
+ $[10] = props;
60
+ $[11] = onSearchChange;
61
+ $[12] = selectProps;
57
62
  } else {
58
- onSearchChange = $[10];
59
- selectProps = $[11];
63
+ onSearchChange = $[11];
64
+ selectProps = $[12];
60
65
  }
61
66
  let t5;
62
- if ($[12] !== handleEnableQuery || $[13] !== onSearchChange || $[14] !== setSearch) {
63
- t5 = (value) => {
64
- setSearch(value);
67
+ if ($[13] !== handleEnableQuery || $[14] !== onSearchChange || $[15] !== setSearch) {
68
+ t5 = (value_0) => {
69
+ setSearch(value_0);
65
70
  handleEnableQuery();
66
- onSearchChange?.(value);
71
+ onSearchChange?.(value_0);
67
72
  };
68
- $[12] = handleEnableQuery;
69
- $[13] = onSearchChange;
70
- $[14] = setSearch;
71
- $[15] = t5;
72
- } else t5 = $[15];
73
+ $[13] = handleEnableQuery;
74
+ $[14] = onSearchChange;
75
+ $[15] = setSearch;
76
+ $[16] = t5;
77
+ } else t5 = $[16];
73
78
  const handleSearchChange = t5;
74
79
  let t6;
75
- if ($[16] !== handleSearchChange || $[17] !== isSearchable) {
80
+ if ($[17] !== handleSearchChange || $[18] !== isSearchable) {
76
81
  t6 = isSearchable && {
77
82
  isClientSearchDisabled: true,
78
83
  onSearchChange: handleSearchChange
79
84
  };
80
- $[16] = handleSearchChange;
81
- $[17] = isSearchable;
82
- $[18] = t6;
83
- } else t6 = $[18];
85
+ $[17] = handleSearchChange;
86
+ $[18] = isSearchable;
87
+ $[19] = t6;
88
+ } else t6 = $[19];
84
89
  let t7;
85
- if ($[19] !== fetchNextPage || $[20] !== handleEnableQuery || $[21] !== hasNextPage || $[22] !== isLoading || $[23] !== items || $[24] !== selectProps || $[25] !== t6 || $[26] !== totalItems) {
90
+ if ($[20] !== fetchNextPage || $[21] !== handleEnableQuery || $[22] !== hasNextPage || $[23] !== isLoading || $[24] !== items || $[25] !== selectProps || $[26] !== t6 || $[27] !== totalItems) {
86
91
  t7 = /* @__PURE__ */ jsx(Select, {
87
92
  ...selectProps,
88
93
  items,
@@ -94,16 +99,16 @@ var QuerySelectContent = (t0) => {
94
99
  onFocusCapture: handleEnableQuery,
95
100
  ...t6
96
101
  });
97
- $[19] = fetchNextPage;
98
- $[20] = handleEnableQuery;
99
- $[21] = hasNextPage;
100
- $[22] = isLoading;
101
- $[23] = items;
102
- $[24] = selectProps;
103
- $[25] = t6;
104
- $[26] = totalItems;
105
- $[27] = t7;
106
- } else t7 = $[27];
102
+ $[20] = fetchNextPage;
103
+ $[21] = handleEnableQuery;
104
+ $[22] = hasNextPage;
105
+ $[23] = isLoading;
106
+ $[24] = items;
107
+ $[25] = selectProps;
108
+ $[26] = t6;
109
+ $[27] = totalItems;
110
+ $[28] = t7;
111
+ } else t7 = $[28];
107
112
  return t7;
108
113
  };
109
114
  var QuerySelect = (props) => {
@@ -3,10 +3,12 @@ import { Key } from 'react-aria-components';
3
3
  import { SelectItem } from './select.types';
4
4
  export type QueryFn<TData = any> = (...args: any[]) => UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
5
5
  export type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
6
- export declare const isInitialSelectionLabelMissing: <TInitialSelectItem>(initialSelection: TInitialSelectItem | TInitialSelectItem[] | null | undefined, mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem) => boolean;
7
- export declare const shouldEnableQueryForSelection: <TInitialSelectItem, TKey extends Key = Key>({ initialSelection, value, mapInitialToSelectItem, }: {
6
+ export declare const getSelectionIdsToResolve: <TInitialSelectItem, TKey extends Key = Key>({ initialSelection, value, mapInitialToSelectItem, }: {
8
7
  initialSelection: TInitialSelectItem | TInitialSelectItem[] | null | undefined;
9
8
  value: TKey | TKey[] | null | undefined;
10
9
  mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
11
- }) => boolean;
10
+ }) => {
11
+ count: number;
12
+ items: TKey[];
13
+ };
12
14
  export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => SelectItem<TKey>[];
@@ -9,18 +9,25 @@ var getInitialSelectionItems = (initialSelection) => {
9
9
  return Array.isArray(initialSelection) ? initialSelection : initialSelection != null ? [initialSelection] : [];
10
10
  };
11
11
  var getInitialSelectionLabel = (initialSelection, mapInitialToSelectItem) => mapInitialToSelectItem?.(initialSelection).label ?? getDefaultInitialSelectionLabel(initialSelection);
12
- var isInitialSelectionLabelMissing = (initialSelection, mapInitialToSelectItem) => {
13
- return getInitialSelectionItems(initialSelection).some((item) => {
14
- return getInitialSelectionLabel(item, mapInitialToSelectItem) === "";
15
- });
16
- };
17
- var shouldEnableQueryForSelection = ({ initialSelection, value, mapInitialToSelectItem }) => {
18
- if (isInitialSelectionLabelMissing(initialSelection, mapInitialToSelectItem)) return true;
12
+ var getSelectionIdsToResolve = ({ initialSelection, value, mapInitialToSelectItem }) => {
19
13
  const values = Array.isArray(value) ? value : value != null ? [value] : [];
20
- if (values.length === 0) return false;
21
14
  const initialSelections = getInitialSelectionItems(initialSelection);
22
- const labeledInitialSelectionIds = new Set(initialSelections.filter((item) => getInitialSelectionLabel(item, mapInitialToSelectItem) !== "").map((item) => mapInitialToSelectItem?.(item).id ?? item.id));
23
- return values.some((id) => !labeledInitialSelectionIds.has(id));
15
+ const labeledInitialSelectionIds = /* @__PURE__ */ new Set();
16
+ const missingLabelInitialSelectionIds = [];
17
+ initialSelections.forEach((item) => {
18
+ const id = (mapInitialToSelectItem?.(item))?.id ?? item.id;
19
+ if (id == null) return;
20
+ if (getInitialSelectionLabel(item, mapInitialToSelectItem) === "") {
21
+ missingLabelInitialSelectionIds.push(id);
22
+ return;
23
+ }
24
+ labeledInitialSelectionIds.add(id);
25
+ });
26
+ const items = Array.from(new Set([...missingLabelInitialSelectionIds, ...values.filter((id) => !labeledInitialSelectionIds.has(id))]));
27
+ return {
28
+ count: items.length,
29
+ items
30
+ };
24
31
  };
25
32
  var getQueryItems = (data, queryMap) => {
26
33
  if (!data) return [];
@@ -33,4 +40,4 @@ var getQueryItems = (data, queryMap) => {
33
40
  return [];
34
41
  };
35
42
  //#endregion
36
- export { getQueryItems, shouldEnableQueryForSelection };
43
+ export { getQueryItems, getSelectionIdsToResolve };
@@ -41,7 +41,7 @@ export declare namespace UIConfig {
41
41
  dateTimeIcon?: ReactElement;
42
42
  timeIcon?: ReactElement;
43
43
  setDateValueOnDateSelection?: boolean;
44
- timeZone: string;
44
+ timeZone?: string;
45
45
  todayIconButtonComponent?: DatePickerProps["todayIconButtonComponent"];
46
46
  };
47
47
  actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
@@ -1,7 +1,7 @@
1
1
  import { InfiniteData } from '@tanstack/react-query';
2
2
  import { Key } from 'react-aria-components';
3
3
  import { InfiniteQueryPage, QueryFn, UseQueryAutocompleteOptions } from '../components/inputs/Selection/Autocomplete/queryAutocomplete.types';
4
- export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, mapItems, initialQueryState, search, }: UseQueryAutocompleteOptions<TQueryFn, TKey>) => {
4
+ export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, mapItems, initialQueryState, search, selectedIdsToResolve, }: UseQueryAutocompleteOptions<TQueryFn, TKey>) => {
5
5
  data: any;
6
6
  isLoading: boolean;
7
7
  isQueryEnabled: boolean;
@@ -1,10 +1,10 @@
1
1
  import { ApiQueryUtils } from "../utils/query.utils.js";
2
- import { useMemo, useState } from "react";
2
+ import { useEffect, useMemo, useState } from "react";
3
3
  //#region src/hooks/useQueryAutocomplete.ts
4
4
  var isFilterSearchParams = (params) => {
5
5
  return typeof params === "object" && params !== null && "filter" in params;
6
6
  };
7
- var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initialQueryState, search }) => {
7
+ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initialQueryState, search, selectedIdsToResolve = [] }) => {
8
8
  "use no memo";
9
9
  const [isQueryEnabled, setIsQueryEnabled] = useState(!initialQueryState);
10
10
  const queryResult = query(search === void 0 ? queryParams : {
@@ -41,6 +41,21 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
41
41
  isInfiniteQuery,
42
42
  mapItems
43
43
  ]);
44
+ const selectedIdsToResolveSet = useMemo(() => new Set(selectedIdsToResolve), [selectedIdsToResolve]);
45
+ useEffect(() => {
46
+ if (!isQueryEnabled || !isInfiniteQuery || !fetchNextPage || !hasNextPage || isFetchingNextPage || selectedIdsToResolveSet.size === 0) return;
47
+ const loadedItemIds = new Set(items.map((item) => item.id));
48
+ if (selectedIdsToResolve.some((id) => !loadedItemIds.has(id))) fetchNextPage();
49
+ }, [
50
+ fetchNextPage,
51
+ hasNextPage,
52
+ isFetchingNextPage,
53
+ isInfiniteQuery,
54
+ isQueryEnabled,
55
+ items,
56
+ selectedIdsToResolve,
57
+ selectedIdsToResolveSet
58
+ ]);
44
59
  return {
45
60
  data,
46
61
  isLoading: isLoading || isFetchingNextPage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "3.0.0-rc.1",
3
+ "version": "3.0.0-rc.2",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",