@povio/ui 3.3.0-rc.4 → 3.4.0-rc.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/README.md +15 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +55 -206
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +9 -34
- package/dist/components/buttons/shared/ButtonContent.js +22 -80
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +93 -100
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +10 -24
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +1 -2
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +109 -113
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +97 -238
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +88 -214
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +64 -143
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +275 -294
- package/dist/components/inputs/DateTime/shared/Calendar.js +139 -339
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +114 -308
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +35 -150
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +95 -229
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +115 -296
- package/dist/components/inputs/DateTime/shared/DateField.js +135 -306
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +136 -343
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +10 -59
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +43 -46
- package/dist/components/inputs/File/FileUpload.d.ts +1 -1
- package/dist/components/inputs/File/FileUpload.js +18 -18
- package/dist/components/inputs/File/InputUpload.d.ts +1 -1
- package/dist/components/inputs/File/InputUpload.js +82 -278
- package/dist/components/inputs/File/fileUpload.types.d.ts +1 -1
- package/dist/components/inputs/File/inputUpload.types.d.ts +1 -1
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +48 -180
- package/dist/components/inputs/File/shared/FileUploadContentError.js +95 -265
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +99 -261
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +56 -234
- package/dist/components/inputs/File/shared/ProgressBar.js +15 -102
- package/dist/components/inputs/FormField/FormField.js +34 -47
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +19 -19
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +93 -331
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.js +18 -18
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
- package/dist/components/inputs/Input/TextInput/TextInput.js +36 -38
- package/dist/components/inputs/Inputs/Form.d.ts +4 -4
- package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
- package/dist/components/inputs/Inputs/InputItem.js +35 -36
- package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.js +107 -111
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +26 -86
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +19 -19
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.js +49 -115
- package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/Select.js +22 -22
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +0 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
- package/dist/components/inputs/Selection/shared/SelectInput.js +1 -0
- package/dist/components/inputs/Selection/shared/SelectListBox.js +51 -163
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/select.context.js +4 -8
- package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/useSelectItems.js +48 -108
- package/dist/components/inputs/Skeleton/InputFrame.js +177 -552
- package/dist/components/inputs/Slider/Slider.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.js +18 -18
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +105 -407
- package/dist/components/inputs/Toggle/Toggle.d.ts +1 -2
- package/dist/components/inputs/Toggle/Toggle.js +59 -63
- package/dist/components/inputs/shared/InputClear.js +24 -40
- package/dist/components/inputs/shared/form.binding.d.ts +27 -0
- package/dist/components/inputs/shared/form.binding.js +57 -0
- package/dist/components/inputs/shared/form.types.d.ts +9 -8
- package/dist/components/inputs/shared/form.types.js +8 -0
- package/dist/components/navigation/Accordion/Accordion.js +22 -69
- package/dist/components/navigation/Accordion/AccordionItem.js +41 -86
- package/dist/components/navigation/Stepper/Stepper.js +22 -67
- package/dist/components/overlays/ActionModal/ActionModal.js +35 -169
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +29 -110
- package/dist/components/segment/Segment.d.ts +1 -1
- package/dist/components/segment/Segment.js +17 -17
- package/dist/components/segment/segment.types.d.ts +1 -1
- package/dist/components/shared/pagination/Pagination.js +22 -108
- package/dist/components/status/Alert/Alert.js +30 -97
- package/dist/components/table/InfiniteTable.js +16 -67
- package/dist/components/table/Table.d.ts +2 -8
- package/dist/components/table/Table.js +33 -55
- package/dist/components/text/Typography/Typography.js +8 -23
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/theme.context.js +45 -98
- package/dist/config/uiConfig.context.d.ts +5 -5
- package/dist/config/uiConfig.context.js +11 -51
- package/dist/config/uiOverrides.context.d.ts +0 -1
- package/dist/helpers/dynamicColumns.d.ts +1 -1
- package/dist/helpers/dynamicInputs.d.ts +7 -7
- package/dist/hooks/useAutosave.d.ts +4 -4
- package/dist/hooks/useAutosave.js +64 -49
- package/dist/hooks/useDebounceCallback.js +17 -51
- package/dist/hooks/useForm.d.ts +39 -15
- package/dist/hooks/useForm.js +96 -43
- package/dist/hooks/useFormAutosave.d.ts +8 -9
- package/dist/hooks/useFormAutosave.js +49 -122
- package/dist/hooks/useLongPressRepeat.js +20 -55
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -4
- package/package.json +3 -4
- package/dist/components/inputs/FormField/formField.cva.d.ts +0 -11
- package/dist/components/inputs/FormField/formField.cva.js +0 -16
- package/dist/components/table/TableColumnFilterInput.d.ts +0 -9
- package/dist/components/table/TableColumnFilterInput.js +0 -108
- package/dist/components/table/TableColumnFilterPlaceholder.d.ts +0 -5
- package/dist/components/table/TableColumnFilterPlaceholder.js +0 -41
- package/dist/components/table/TableColumnFilterRow.d.ts +0 -16
- package/dist/components/table/TableColumnFilterRow.js +0 -68
- package/dist/hooks/useAutosave.spec.d.ts +0 -1
|
@@ -16,8 +16,8 @@ import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
|
16
16
|
import { mergeRefs } from "@react-aria/utils";
|
|
17
17
|
//#region src/components/inputs/DateTime/shared/TimePickerInput.tsx
|
|
18
18
|
var TimePickerInput = (t0) => {
|
|
19
|
-
const $ = c(
|
|
20
|
-
const { ref, as, fieldProps, state, isDisabled, isDirty, isRequired, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, onClear,
|
|
19
|
+
const $ = c(67);
|
|
20
|
+
const { ref, as, fieldProps, state, isDisabled, isDirty, isRequired, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, onClear, ...props } = t0;
|
|
21
21
|
const uiConfig = UIConfig.useConfig();
|
|
22
22
|
const inputBaseCva = UIOverrides.useCva("input.baseCva", inputBaseDefinition);
|
|
23
23
|
const inputSizeCva = UIOverrides.useCva("input.sizeCva", inputSizeDefinition);
|
|
@@ -147,25 +147,22 @@ var TimePickerInput = (t0) => {
|
|
|
147
147
|
$[32] = t22;
|
|
148
148
|
} else t22 = $[32];
|
|
149
149
|
let t23;
|
|
150
|
-
if ($[33] !== canClear || $[34] !==
|
|
150
|
+
if ($[33] !== canClear || $[34] !== isClearable || $[35] !== onClear || $[36] !== state) {
|
|
151
151
|
t23 = isClearable && /* @__PURE__ */ jsx(InputClear, {
|
|
152
152
|
onClear: () => {
|
|
153
153
|
state.setValue(null);
|
|
154
154
|
onClear?.();
|
|
155
|
-
if (fireBlurOnChange) fieldProps.onBlur?.(null);
|
|
156
155
|
},
|
|
157
156
|
show: canClear
|
|
158
157
|
});
|
|
159
158
|
$[33] = canClear;
|
|
160
|
-
$[34] =
|
|
161
|
-
$[35] =
|
|
162
|
-
$[36] =
|
|
163
|
-
$[37] =
|
|
164
|
-
|
|
165
|
-
$[39] = t23;
|
|
166
|
-
} else t23 = $[39];
|
|
159
|
+
$[34] = isClearable;
|
|
160
|
+
$[35] = onClear;
|
|
161
|
+
$[36] = state;
|
|
162
|
+
$[37] = t23;
|
|
163
|
+
} else t23 = $[37];
|
|
167
164
|
let t24;
|
|
168
|
-
if ($[
|
|
165
|
+
if ($[38] !== disableDropdown || $[39] !== disableManualEntry || $[40] !== isDisabled || $[41] !== onPress || $[42] !== uiConfig) {
|
|
169
166
|
t24 = (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
|
|
170
167
|
label: "",
|
|
171
168
|
color: "secondary",
|
|
@@ -175,26 +172,26 @@ var TimePickerInput = (t0) => {
|
|
|
175
172
|
className: "border-0!",
|
|
176
173
|
"data-static-press-action": ""
|
|
177
174
|
});
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
} else t24 = $[
|
|
175
|
+
$[38] = disableDropdown;
|
|
176
|
+
$[39] = disableManualEntry;
|
|
177
|
+
$[40] = isDisabled;
|
|
178
|
+
$[41] = onPress;
|
|
179
|
+
$[42] = uiConfig;
|
|
180
|
+
$[43] = t24;
|
|
181
|
+
} else t24 = $[43];
|
|
185
182
|
let t25;
|
|
186
|
-
if ($[
|
|
183
|
+
if ($[44] !== t22 || $[45] !== t23 || $[46] !== t24) {
|
|
187
184
|
t25 = /* @__PURE__ */ jsxs("div", {
|
|
188
185
|
className: t22,
|
|
189
186
|
children: [t23, t24]
|
|
190
187
|
});
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
} else t25 = $[
|
|
188
|
+
$[44] = t22;
|
|
189
|
+
$[45] = t23;
|
|
190
|
+
$[46] = t24;
|
|
191
|
+
$[47] = t25;
|
|
192
|
+
} else t25 = $[47];
|
|
196
193
|
let t26;
|
|
197
|
-
if ($[
|
|
194
|
+
if ($[48] !== fieldProps || $[49] !== focusWithinProps || $[50] !== hoverProps || $[51] !== t10 || $[52] !== t11 || $[53] !== t12 || $[54] !== t13 || $[55] !== t14 || $[56] !== t15 || $[57] !== t16 || $[58] !== t21 || $[59] !== t25 || $[60] !== t4 || $[61] !== t5 || $[62] !== t6 || $[63] !== t7 || $[64] !== t8 || $[65] !== t9) {
|
|
198
195
|
t26 = /* @__PURE__ */ jsxs("div", {
|
|
199
196
|
ref: t4,
|
|
200
197
|
className: t5,
|
|
@@ -216,26 +213,26 @@ var TimePickerInput = (t0) => {
|
|
|
216
213
|
...hoverProps,
|
|
217
214
|
children: [t21, t25]
|
|
218
215
|
});
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
$[
|
|
238
|
-
} else t26 = $[
|
|
216
|
+
$[48] = fieldProps;
|
|
217
|
+
$[49] = focusWithinProps;
|
|
218
|
+
$[50] = hoverProps;
|
|
219
|
+
$[51] = t10;
|
|
220
|
+
$[52] = t11;
|
|
221
|
+
$[53] = t12;
|
|
222
|
+
$[54] = t13;
|
|
223
|
+
$[55] = t14;
|
|
224
|
+
$[56] = t15;
|
|
225
|
+
$[57] = t16;
|
|
226
|
+
$[58] = t21;
|
|
227
|
+
$[59] = t25;
|
|
228
|
+
$[60] = t4;
|
|
229
|
+
$[61] = t5;
|
|
230
|
+
$[62] = t6;
|
|
231
|
+
$[63] = t7;
|
|
232
|
+
$[64] = t8;
|
|
233
|
+
$[65] = t9;
|
|
234
|
+
$[66] = t26;
|
|
235
|
+
} else t26 = $[66];
|
|
239
236
|
return t26;
|
|
240
237
|
};
|
|
241
238
|
function _temp(segment) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldValues } from '
|
|
1
|
+
import { FieldValues } from '../shared/form.binding';
|
|
2
2
|
import { FileUploadProps } from './fileUpload.types';
|
|
3
3
|
export type { DefaultFile, FileUploadBaseProps, FileUploadButtonProps, FileUploadError, FileUploadProps, FileUploadRequest, FileUploadResponse, FileUploadState, } from './fileUpload.types';
|
|
4
4
|
export declare const FileUpload: <TFieldValues extends FieldValues = FieldValues>(props: FileUploadProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UIOverrides } from "../../../config/uiOverrides.context.js";
|
|
2
2
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
3
3
|
import "../../../config/i18n.js";
|
|
4
|
+
import { FieldController } from "../shared/form.binding.js";
|
|
4
5
|
import { FormField } from "../FormField/FormField.js";
|
|
5
6
|
import { FileUtils } from "../../../utils/file.utils.js";
|
|
6
7
|
import { FileCardList } from "./shared/FileCardList.js";
|
|
@@ -14,11 +15,10 @@ import { useCallback, useState } from "react";
|
|
|
14
15
|
import { DropZone } from "react-aria-components";
|
|
15
16
|
import { mergeRefs, useLabels } from "@react-aria/utils";
|
|
16
17
|
import { useTranslation } from "react-i18next";
|
|
17
|
-
import { Controller } from "react-hook-form";
|
|
18
18
|
//#region src/components/inputs/File/FileUpload.tsx
|
|
19
19
|
var FileUploadBase = (props) => {
|
|
20
20
|
const { t } = useTranslation("ui");
|
|
21
|
-
const { ref: _ref, label, tooltipText, variant = "vertical", as = "button", helperText, isRequired, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, className, allowsMultiple = false, hideLabel, acceptedFileTypes, clearOnSuccess, emptyText = t(($) => $.ui.fileUpload.emptyText), uploadText = t(($
|
|
21
|
+
const { ref: _ref, label, tooltipText, variant = "vertical", as = "button", helperText, isRequired, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, className, allowsMultiple = false, hideLabel, acceptedFileTypes, clearOnSuccess, emptyText = t(($) => $.ui.fileUpload.emptyText), uploadText = t(($) => $.ui.fileUpload.uploadText), browseText = t(($) => $.ui.fileUpload.browse), fileUpload, fileRemove, children, listRenderer, browseButtonProps, cancelButtonProps, onInvalidFileType, defaultState, ...rest } = props;
|
|
22
22
|
const ui = UIConfig.useConfig();
|
|
23
23
|
const fileUploadDropZoneCva = UIOverrides.useCva("fileUpload.dropZoneCva", fileUploadDropZoneDefinition);
|
|
24
24
|
const getInitialState = () => {
|
|
@@ -192,32 +192,32 @@ var FileUploadBase = (props) => {
|
|
|
192
192
|
};
|
|
193
193
|
var FileUpload = (props) => {
|
|
194
194
|
const $ = c(15);
|
|
195
|
-
if ("
|
|
196
|
-
let
|
|
195
|
+
if ("field" in props && props.field) {
|
|
196
|
+
let field;
|
|
197
197
|
let innerProps;
|
|
198
198
|
let ref;
|
|
199
199
|
if ($[0] !== props) {
|
|
200
|
-
({
|
|
200
|
+
({field, ref, ...innerProps} = props);
|
|
201
201
|
$[0] = props;
|
|
202
|
-
$[1] =
|
|
202
|
+
$[1] = field;
|
|
203
203
|
$[2] = innerProps;
|
|
204
204
|
$[3] = ref;
|
|
205
205
|
} else {
|
|
206
|
-
|
|
206
|
+
field = $[1];
|
|
207
207
|
innerProps = $[2];
|
|
208
208
|
ref = $[3];
|
|
209
209
|
}
|
|
210
210
|
let t0;
|
|
211
211
|
if ($[4] !== innerProps || $[5] !== props.error || $[6] !== props.isDisabled || $[7] !== ref) {
|
|
212
212
|
t0 = (t1) => {
|
|
213
|
-
const { field, fieldState: t2 } = t1;
|
|
213
|
+
const { field: field_0, fieldState: t2 } = t1;
|
|
214
214
|
const { error } = t2;
|
|
215
215
|
return /* @__PURE__ */ jsx(FileUploadBase, {
|
|
216
216
|
...innerProps,
|
|
217
|
-
ref: mergeRefs(ref,
|
|
218
|
-
value:
|
|
219
|
-
onChange:
|
|
220
|
-
isDisabled:
|
|
217
|
+
ref: mergeRefs(ref, field_0.ref),
|
|
218
|
+
value: field_0.value,
|
|
219
|
+
onChange: field_0.onChange,
|
|
220
|
+
isDisabled: field_0.disabled || props.isDisabled,
|
|
221
221
|
error: props.error ?? error?.message
|
|
222
222
|
});
|
|
223
223
|
};
|
|
@@ -228,14 +228,14 @@ var FileUpload = (props) => {
|
|
|
228
228
|
$[8] = t0;
|
|
229
229
|
} else t0 = $[8];
|
|
230
230
|
let t1;
|
|
231
|
-
if ($[9] !==
|
|
232
|
-
t1 = /* @__PURE__ */ jsx(
|
|
233
|
-
control:
|
|
234
|
-
name:
|
|
231
|
+
if ($[9] !== field.form || $[10] !== field.name || $[11] !== t0) {
|
|
232
|
+
t1 = /* @__PURE__ */ jsx(FieldController, {
|
|
233
|
+
control: field.form,
|
|
234
|
+
name: field.name,
|
|
235
235
|
render: t0
|
|
236
236
|
});
|
|
237
|
-
$[9] =
|
|
238
|
-
$[10] =
|
|
237
|
+
$[9] = field.form;
|
|
238
|
+
$[10] = field.name;
|
|
239
239
|
$[11] = t0;
|
|
240
240
|
$[12] = t1;
|
|
241
241
|
} else t1 = $[12];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldValues } from '
|
|
1
|
+
import { FieldValues } from '../shared/form.binding';
|
|
2
2
|
import { InputUploadProps } from './inputUpload.types';
|
|
3
3
|
export type { InputUploadBaseProps, InputUploadProps } from './inputUpload.types';
|
|
4
4
|
export declare const InputUpload: <TFieldValues extends FieldValues = FieldValues>(props: InputUploadProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
2
|
+
import { FieldController } from "../shared/form.binding.js";
|
|
2
3
|
import { FormField } from "../FormField/FormField.js";
|
|
3
4
|
import { FileUtils } from "../../../utils/file.utils.js";
|
|
4
5
|
import { InputUploadContent } from "./shared/InputUploadContent.js";
|
|
@@ -8,239 +9,73 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
9
|
import { clsx } from "clsx";
|
|
9
10
|
import { useState } from "react";
|
|
10
11
|
import { mergeRefs, useLabels } from "@react-aria/utils";
|
|
11
|
-
import { Controller } from "react-hook-form";
|
|
12
12
|
//#region src/components/inputs/File/InputUpload.tsx
|
|
13
|
-
var InputUploadBase = (
|
|
14
|
-
const $ = c(78);
|
|
15
|
-
let acceptedFileTypes;
|
|
16
|
-
let className;
|
|
17
|
-
let defaultValue;
|
|
18
|
-
let error;
|
|
19
|
-
let errorClassName;
|
|
20
|
-
let headerClassName;
|
|
21
|
-
let helperText;
|
|
22
|
-
let hideLabel;
|
|
23
|
-
let isDisabled;
|
|
24
|
-
let isHeaderHidden;
|
|
25
|
-
let isRequired;
|
|
26
|
-
let label;
|
|
27
|
-
let onChange;
|
|
28
|
-
let onInvalidFileType;
|
|
29
|
-
let rest;
|
|
30
|
-
let size;
|
|
31
|
-
let t1;
|
|
32
|
-
let tooltipText;
|
|
33
|
-
let value;
|
|
34
|
-
let variant;
|
|
35
|
-
if ($[0] !== t0) {
|
|
36
|
-
const { ref: _ref, label: t2, tooltipText: t3, variant: t4, helperText: t5, isRequired: t6, isDisabled: t7, headerClassName: t8, errorClassName: t9, isHeaderHidden: t10, error: t11, className: t12, onChange: t13, onInvalidFileType: t14, value: t15, defaultValue: t16, allowsMultiple: t17, hideLabel: t18, acceptedFileTypes: t19, size: t20, ...t21 } = t0;
|
|
37
|
-
label = t2;
|
|
38
|
-
tooltipText = t3;
|
|
39
|
-
variant = t4;
|
|
40
|
-
helperText = t5;
|
|
41
|
-
isRequired = t6;
|
|
42
|
-
isDisabled = t7;
|
|
43
|
-
headerClassName = t8;
|
|
44
|
-
errorClassName = t9;
|
|
45
|
-
isHeaderHidden = t10;
|
|
46
|
-
error = t11;
|
|
47
|
-
className = t12;
|
|
48
|
-
onChange = t13;
|
|
49
|
-
onInvalidFileType = t14;
|
|
50
|
-
value = t15;
|
|
51
|
-
defaultValue = t16;
|
|
52
|
-
t1 = t17;
|
|
53
|
-
hideLabel = t18;
|
|
54
|
-
acceptedFileTypes = t19;
|
|
55
|
-
size = t20;
|
|
56
|
-
rest = t21;
|
|
57
|
-
$[0] = t0;
|
|
58
|
-
$[1] = acceptedFileTypes;
|
|
59
|
-
$[2] = className;
|
|
60
|
-
$[3] = defaultValue;
|
|
61
|
-
$[4] = error;
|
|
62
|
-
$[5] = errorClassName;
|
|
63
|
-
$[6] = headerClassName;
|
|
64
|
-
$[7] = helperText;
|
|
65
|
-
$[8] = hideLabel;
|
|
66
|
-
$[9] = isDisabled;
|
|
67
|
-
$[10] = isHeaderHidden;
|
|
68
|
-
$[11] = isRequired;
|
|
69
|
-
$[12] = label;
|
|
70
|
-
$[13] = onChange;
|
|
71
|
-
$[14] = onInvalidFileType;
|
|
72
|
-
$[15] = rest;
|
|
73
|
-
$[16] = size;
|
|
74
|
-
$[17] = t1;
|
|
75
|
-
$[18] = tooltipText;
|
|
76
|
-
$[19] = value;
|
|
77
|
-
$[20] = variant;
|
|
78
|
-
} else {
|
|
79
|
-
acceptedFileTypes = $[1];
|
|
80
|
-
className = $[2];
|
|
81
|
-
defaultValue = $[3];
|
|
82
|
-
error = $[4];
|
|
83
|
-
errorClassName = $[5];
|
|
84
|
-
headerClassName = $[6];
|
|
85
|
-
helperText = $[7];
|
|
86
|
-
hideLabel = $[8];
|
|
87
|
-
isDisabled = $[9];
|
|
88
|
-
isHeaderHidden = $[10];
|
|
89
|
-
isRequired = $[11];
|
|
90
|
-
label = $[12];
|
|
91
|
-
onChange = $[13];
|
|
92
|
-
onInvalidFileType = $[14];
|
|
93
|
-
rest = $[15];
|
|
94
|
-
size = $[16];
|
|
95
|
-
t1 = $[17];
|
|
96
|
-
tooltipText = $[18];
|
|
97
|
-
value = $[19];
|
|
98
|
-
variant = $[20];
|
|
99
|
-
}
|
|
100
|
-
const allowsMultiple = t1 === void 0 ? false : t1;
|
|
13
|
+
var InputUploadBase = ({ ref: _ref, label, tooltipText, variant, helperText, isRequired, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, className, onChange, onInvalidFileType, value, defaultValue, allowsMultiple = false, hideLabel, acceptedFileTypes, size, ...rest }) => {
|
|
101
14
|
const ui = UIConfig.useConfig();
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
t2 = () => {
|
|
105
|
-
if (value !== void 0) {
|
|
106
|
-
if (allowsMultiple) return value || [];
|
|
107
|
-
return value ? [value] : [];
|
|
108
|
-
}
|
|
109
|
-
if (defaultValue !== void 0) {
|
|
110
|
-
if (allowsMultiple) return defaultValue || [];
|
|
111
|
-
return defaultValue ? [defaultValue] : [];
|
|
112
|
-
}
|
|
113
|
-
return [];
|
|
114
|
-
};
|
|
115
|
-
$[21] = allowsMultiple;
|
|
116
|
-
$[22] = defaultValue;
|
|
117
|
-
$[23] = value;
|
|
118
|
-
$[24] = t2;
|
|
119
|
-
} else t2 = $[24];
|
|
120
|
-
const [internalFiles, setInternalFiles] = useState(t2);
|
|
121
|
-
let t3;
|
|
122
|
-
if ($[25] !== allowsMultiple || $[26] !== internalFiles || $[27] !== value) {
|
|
123
|
-
t3 = value !== void 0 ? (() => {
|
|
15
|
+
const [internalFiles, setInternalFiles] = useState(() => {
|
|
16
|
+
if (value !== void 0) {
|
|
124
17
|
if (allowsMultiple) return value || [];
|
|
125
18
|
return value ? [value] : [];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (allowsMultiple) {
|
|
187
|
-
updateFiles([...files, ...acceptedFiles]);
|
|
188
|
-
if (invalidFiles.length > 0) onInvalidFileType?.(invalidFiles.map(_temp));
|
|
189
|
-
} else {
|
|
190
|
-
if (acceptedFiles.length > 0) updateFiles([acceptedFiles[0]]);
|
|
191
|
-
if (invalidFiles.length > 0) onInvalidFileType?.(invalidFiles[0].name);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
$[46] = acceptedFileTypes;
|
|
195
|
-
$[47] = allowsMultiple;
|
|
196
|
-
$[48] = files;
|
|
197
|
-
$[49] = onInvalidFileType;
|
|
198
|
-
$[50] = updateFiles;
|
|
199
|
-
$[51] = t8;
|
|
200
|
-
} else t8 = $[51];
|
|
201
|
-
const handleFileSelect = t8;
|
|
202
|
-
let t9;
|
|
203
|
-
if ($[52] !== handleFileSelect) {
|
|
204
|
-
t9 = (inputFiles_0) => {
|
|
205
|
-
if (!inputFiles_0) return;
|
|
206
|
-
handleFileSelect(Array.from(inputFiles_0));
|
|
207
|
-
};
|
|
208
|
-
$[52] = handleFileSelect;
|
|
209
|
-
$[53] = t9;
|
|
210
|
-
} else t9 = $[53];
|
|
211
|
-
const handleSelect = t9;
|
|
212
|
-
let t10;
|
|
213
|
-
if ($[54] !== handleFileSelect) {
|
|
214
|
-
t10 = async (e) => {
|
|
215
|
-
if (!e.items) return;
|
|
216
|
-
const promises = [];
|
|
217
|
-
e.items.forEach((item) => {
|
|
218
|
-
if (item.kind === "file") promises.push(item.getFile());
|
|
219
|
-
});
|
|
220
|
-
handleFileSelect(await Promise.all(promises));
|
|
221
|
-
};
|
|
222
|
-
$[54] = handleFileSelect;
|
|
223
|
-
$[55] = t10;
|
|
224
|
-
} else t10 = $[55];
|
|
225
|
-
const handleDrop = t10;
|
|
226
|
-
let t11;
|
|
227
|
-
if ($[56] !== updateFiles) {
|
|
228
|
-
t11 = () => {
|
|
229
|
-
updateFiles([]);
|
|
230
|
-
};
|
|
231
|
-
$[56] = updateFiles;
|
|
232
|
-
$[57] = t11;
|
|
233
|
-
} else t11 = $[57];
|
|
234
|
-
const handleRemove = t11;
|
|
235
|
-
let t12;
|
|
236
|
-
if ($[58] !== className) {
|
|
237
|
-
t12 = clsx("group w-full", className);
|
|
238
|
-
$[58] = className;
|
|
239
|
-
$[59] = t12;
|
|
240
|
-
} else t12 = $[59];
|
|
241
|
-
let t13;
|
|
242
|
-
if ($[60] !== acceptedFileTypes || $[61] !== allowsMultiple || $[62] !== error || $[63] !== files || $[64] !== handleDrop || $[65] !== handleRemove || $[66] !== handleSelect || $[67] !== isDisabled || $[68] !== label || $[69] !== rest || $[70] !== size || $[71] !== variant) {
|
|
243
|
-
t13 = files.length > 0 ? /* @__PURE__ */ jsx(InputUploadFilled, {
|
|
19
|
+
}
|
|
20
|
+
if (defaultValue !== void 0) {
|
|
21
|
+
if (allowsMultiple) return defaultValue || [];
|
|
22
|
+
return defaultValue ? [defaultValue] : [];
|
|
23
|
+
}
|
|
24
|
+
return [];
|
|
25
|
+
});
|
|
26
|
+
const files = value !== void 0 ? (() => {
|
|
27
|
+
if (allowsMultiple) return value || [];
|
|
28
|
+
return value ? [value] : [];
|
|
29
|
+
})() : internalFiles;
|
|
30
|
+
const formFieldProps = {
|
|
31
|
+
error,
|
|
32
|
+
label,
|
|
33
|
+
tooltipText,
|
|
34
|
+
helperText,
|
|
35
|
+
isRequired,
|
|
36
|
+
isHeaderHidden,
|
|
37
|
+
hideLabel: hideLabel ?? ui.input.hideLabel,
|
|
38
|
+
isDisabled,
|
|
39
|
+
headerClassName,
|
|
40
|
+
errorClassName
|
|
41
|
+
};
|
|
42
|
+
const labelProps = useLabels({ "aria-label": label });
|
|
43
|
+
const updateFiles = (newFiles) => {
|
|
44
|
+
if (value === void 0) setInternalFiles(newFiles);
|
|
45
|
+
if (allowsMultiple) onChange?.(newFiles);
|
|
46
|
+
else onChange?.(newFiles[0] || null);
|
|
47
|
+
};
|
|
48
|
+
const handleFileSelect = (inputFiles) => {
|
|
49
|
+
const acceptedFiles = inputFiles.filter((file) => FileUtils.isFileTypeAccepted(file, acceptedFileTypes));
|
|
50
|
+
const invalidFiles = inputFiles.filter((file_0) => !FileUtils.isFileTypeAccepted(file_0, acceptedFileTypes));
|
|
51
|
+
if (allowsMultiple) {
|
|
52
|
+
updateFiles([...files, ...acceptedFiles]);
|
|
53
|
+
if (invalidFiles.length > 0) onInvalidFileType?.(invalidFiles.map((file_1) => file_1.name));
|
|
54
|
+
} else {
|
|
55
|
+
if (acceptedFiles.length > 0) updateFiles([acceptedFiles[0]]);
|
|
56
|
+
if (invalidFiles.length > 0) onInvalidFileType?.(invalidFiles[0].name);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const handleSelect = (inputFiles_0) => {
|
|
60
|
+
if (!inputFiles_0) return;
|
|
61
|
+
handleFileSelect(Array.from(inputFiles_0));
|
|
62
|
+
};
|
|
63
|
+
const handleDrop = async (e) => {
|
|
64
|
+
if (!e.items) return;
|
|
65
|
+
const promises = [];
|
|
66
|
+
e.items.forEach((item) => {
|
|
67
|
+
if (item.kind === "file") promises.push(item.getFile());
|
|
68
|
+
});
|
|
69
|
+
handleFileSelect(await Promise.all(promises));
|
|
70
|
+
};
|
|
71
|
+
const handleRemove = () => {
|
|
72
|
+
updateFiles([]);
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
75
|
+
...formFieldProps,
|
|
76
|
+
labelProps,
|
|
77
|
+
className: clsx("group w-full", className),
|
|
78
|
+
children: files.length > 0 ? /* @__PURE__ */ jsx(InputUploadFilled, {
|
|
244
79
|
files,
|
|
245
80
|
onRemove: handleRemove,
|
|
246
81
|
isDisabled,
|
|
@@ -256,65 +91,37 @@ var InputUploadBase = (t0) => {
|
|
|
256
91
|
onSelect: handleSelect,
|
|
257
92
|
onDrop: handleDrop,
|
|
258
93
|
size
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
$[61] = allowsMultiple;
|
|
262
|
-
$[62] = error;
|
|
263
|
-
$[63] = files;
|
|
264
|
-
$[64] = handleDrop;
|
|
265
|
-
$[65] = handleRemove;
|
|
266
|
-
$[66] = handleSelect;
|
|
267
|
-
$[67] = isDisabled;
|
|
268
|
-
$[68] = label;
|
|
269
|
-
$[69] = rest;
|
|
270
|
-
$[70] = size;
|
|
271
|
-
$[71] = variant;
|
|
272
|
-
$[72] = t13;
|
|
273
|
-
} else t13 = $[72];
|
|
274
|
-
let t14;
|
|
275
|
-
if ($[73] !== formFieldProps || $[74] !== labelProps || $[75] !== t12 || $[76] !== t13) {
|
|
276
|
-
t14 = /* @__PURE__ */ jsx(FormField, {
|
|
277
|
-
...formFieldProps,
|
|
278
|
-
labelProps,
|
|
279
|
-
className: t12,
|
|
280
|
-
children: t13
|
|
281
|
-
});
|
|
282
|
-
$[73] = formFieldProps;
|
|
283
|
-
$[74] = labelProps;
|
|
284
|
-
$[75] = t12;
|
|
285
|
-
$[76] = t13;
|
|
286
|
-
$[77] = t14;
|
|
287
|
-
} else t14 = $[77];
|
|
288
|
-
return t14;
|
|
94
|
+
})
|
|
95
|
+
});
|
|
289
96
|
};
|
|
290
97
|
var InputUpload = (props) => {
|
|
291
98
|
const $ = c(15);
|
|
292
|
-
if ("
|
|
293
|
-
let
|
|
99
|
+
if ("field" in props && props.field) {
|
|
100
|
+
let field;
|
|
294
101
|
let innerProps;
|
|
295
102
|
let ref;
|
|
296
103
|
if ($[0] !== props) {
|
|
297
|
-
({
|
|
104
|
+
({field, ref, ...innerProps} = props);
|
|
298
105
|
$[0] = props;
|
|
299
|
-
$[1] =
|
|
106
|
+
$[1] = field;
|
|
300
107
|
$[2] = innerProps;
|
|
301
108
|
$[3] = ref;
|
|
302
109
|
} else {
|
|
303
|
-
|
|
110
|
+
field = $[1];
|
|
304
111
|
innerProps = $[2];
|
|
305
112
|
ref = $[3];
|
|
306
113
|
}
|
|
307
114
|
let t0;
|
|
308
115
|
if ($[4] !== innerProps || $[5] !== props.error || $[6] !== props.isDisabled || $[7] !== ref) {
|
|
309
116
|
t0 = (t1) => {
|
|
310
|
-
const { field, fieldState: t2 } = t1;
|
|
117
|
+
const { field: field_0, fieldState: t2 } = t1;
|
|
311
118
|
const { error } = t2;
|
|
312
119
|
return /* @__PURE__ */ jsx(InputUploadBase, {
|
|
313
120
|
...innerProps,
|
|
314
|
-
ref: mergeRefs(ref,
|
|
315
|
-
value:
|
|
316
|
-
onChange:
|
|
317
|
-
isDisabled:
|
|
121
|
+
ref: mergeRefs(ref, field_0.ref),
|
|
122
|
+
value: field_0.value,
|
|
123
|
+
onChange: field_0.onChange,
|
|
124
|
+
isDisabled: field_0.disabled || props.isDisabled,
|
|
318
125
|
error: props.error ?? error?.message
|
|
319
126
|
});
|
|
320
127
|
};
|
|
@@ -325,14 +132,14 @@ var InputUpload = (props) => {
|
|
|
325
132
|
$[8] = t0;
|
|
326
133
|
} else t0 = $[8];
|
|
327
134
|
let t1;
|
|
328
|
-
if ($[9] !==
|
|
329
|
-
t1 = /* @__PURE__ */ jsx(
|
|
330
|
-
control:
|
|
331
|
-
name:
|
|
135
|
+
if ($[9] !== field.form || $[10] !== field.name || $[11] !== t0) {
|
|
136
|
+
t1 = /* @__PURE__ */ jsx(FieldController, {
|
|
137
|
+
control: field.form,
|
|
138
|
+
name: field.name,
|
|
332
139
|
render: t0
|
|
333
140
|
});
|
|
334
|
-
$[9] =
|
|
335
|
-
$[10] =
|
|
141
|
+
$[9] = field.form;
|
|
142
|
+
$[10] = field.name;
|
|
336
143
|
$[11] = t0;
|
|
337
144
|
$[12] = t1;
|
|
338
145
|
} else t1 = $[12];
|
|
@@ -346,8 +153,5 @@ var InputUpload = (props) => {
|
|
|
346
153
|
} else t0 = $[14];
|
|
347
154
|
return t0;
|
|
348
155
|
};
|
|
349
|
-
function _temp(file_1) {
|
|
350
|
-
return file_1.name;
|
|
351
|
-
}
|
|
352
156
|
//#endregion
|
|
353
157
|
export { InputUpload };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, Ref } from 'react';
|
|
2
2
|
import { DropZoneProps, FileTriggerProps } from 'react-aria-components';
|
|
3
|
-
import { FieldValues } from '
|
|
3
|
+
import { FieldValues } from '../shared/form.binding';
|
|
4
4
|
import { ButtonProps } from '../../buttons/Button/Button';
|
|
5
5
|
import { FormFieldProps } from '../FormField/FormField';
|
|
6
6
|
import { ControlProps } from '../shared/form.types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { DropZoneProps, FileTriggerProps } from 'react-aria-components';
|
|
3
|
-
import { FieldValues } from '
|
|
3
|
+
import { FieldValues } from '../shared/form.binding';
|
|
4
4
|
import { FormFieldProps } from '../FormField/FormField';
|
|
5
5
|
import { ControlProps } from '../shared/form.types';
|
|
6
6
|
import { InputUploadButtonProps } from './shared/inputUploadButton.cva';
|