@oslokommune/punkt-react 16.25.1 → 16.26.3
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/CHANGELOG.md +28 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +1 -1
- package/dist/components/accordion/Accordion.d.ts +21 -0
- package/dist/components/accordion/Accordion.test.d.ts +0 -0
- package/dist/components/accordion/AccordionItem.d.ts +17 -0
- package/dist/components/alert/Alert.d.ts +14 -0
- package/dist/components/alert/Alert.test.d.ts +0 -0
- package/dist/components/backlink/BackLink.d.ts +14 -0
- package/dist/components/backlink/BackLink.test.d.ts +0 -0
- package/dist/components/breadcrumbs/Breadcrumbs.d.ts +16 -0
- package/dist/components/breadcrumbs/Breadcrumbs.test.d.ts +1 -0
- package/dist/components/button/Button.d.ts +24 -0
- package/dist/components/button/Button.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.accessibility.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.constraints.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.core.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.d.ts +3 -0
- package/dist/components/calendar/Calendar.interaction.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.selection.test.d.ts +0 -0
- package/dist/components/calendar/CalendarGrid.d.ts +4 -0
- package/dist/components/calendar/CalendarNav.d.ts +2 -0
- package/dist/components/calendar/calendar-utils.d.ts +20 -0
- package/dist/components/calendar/types.d.ts +104 -0
- package/dist/components/calendar/useCalendarState.d.ts +2 -0
- package/dist/components/card/Card.d.ts +37 -0
- package/dist/components/card/Card.test.d.ts +0 -0
- package/dist/components/checkbox/Checkbox.d.ts +23 -0
- package/dist/components/checkbox/Checkbox.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.accessibility.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.core.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.d.ts +3 -0
- package/dist/components/combobox/Combobox.interaction.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.selection.test.d.ts +0 -0
- package/dist/components/combobox/ComboboxInput.d.ts +6 -0
- package/dist/components/combobox/ComboboxTags.d.ts +11 -0
- package/dist/components/combobox/Listbox.d.ts +6 -0
- package/dist/components/combobox/types.d.ts +104 -0
- package/dist/components/combobox/useComboboxState.d.ts +2 -0
- package/dist/components/consent/Consent.d.ts +51 -0
- package/dist/components/consent/Consent.test.d.ts +0 -0
- package/dist/components/consent/strings.d.ts +85 -0
- package/dist/components/datepicker/DateTags.d.ts +10 -0
- package/dist/components/datepicker/Datepicker.accessibility.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.core.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.d.ts +3 -0
- package/dist/components/datepicker/Datepicker.input.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.selection.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.validation.test.d.ts +0 -0
- package/dist/components/datepicker/DatepickerInputs.d.ts +4 -0
- package/dist/components/datepicker/DatepickerPopup.d.ts +21 -0
- package/dist/components/datepicker/types.d.ts +109 -0
- package/dist/components/datepicker/useDatepickerState.d.ts +2 -0
- package/dist/components/fileupload/DropZone.d.ts +42 -0
- package/dist/components/fileupload/FileUpload.d.ts +84 -0
- package/dist/components/fileupload/FileUpload.test.d.ts +0 -0
- package/dist/components/fileupload/QueueDisplay.d.ts +19 -0
- package/dist/components/fileupload/QueueDisplay.test.d.ts +0 -0
- package/dist/components/fileupload/QueueItemContent.d.ts +44 -0
- package/dist/components/fileupload/Subcomponents.d.ts +36 -0
- package/dist/components/fileupload/Truncate.d.ts +20 -0
- package/dist/components/fileupload/Truncate.test.d.ts +0 -0
- package/dist/components/fileupload/extensions/Comments.d.ts +6 -0
- package/dist/components/fileupload/extensions/Remove.d.ts +2 -0
- package/dist/components/fileupload/extensions/Rename.d.ts +2 -0
- package/dist/components/fileupload/hooks/index.d.ts +4 -0
- package/dist/components/fileupload/hooks/useFileAttributes.d.ts +10 -0
- package/dist/components/fileupload/hooks/useImagePreview.d.ts +9 -0
- package/dist/components/fileupload/hooks/useOperationState.d.ts +6 -0
- package/dist/components/fileupload/hooks/useRequiredFormValidation.d.ts +16 -0
- package/dist/components/fileupload/hooks.d.ts +4 -0
- package/dist/components/fileupload/types.d.ts +88 -0
- package/dist/components/fileupload/utils.d.ts +5 -0
- package/dist/components/footer/Footer.d.ts +36 -0
- package/dist/components/footer/Footer.test.d.ts +0 -0
- package/dist/components/footerSimple/FooterSimple.d.ts +21 -0
- package/dist/components/footerSimple/FooterSimple.test.d.ts +0 -0
- package/dist/components/header/Header.d.ts +15 -0
- package/dist/components/header/Header.test.d.ts +0 -0
- package/dist/components/header/HeaderService.d.ts +9 -0
- package/dist/components/header/HeaderService.test.d.ts +0 -0
- package/dist/components/header/types.d.ts +93 -0
- package/dist/components/header-menu/HeaderMenu.d.ts +26 -0
- package/dist/components/header-menu/HeaderMenu.test.d.ts +0 -0
- package/dist/components/headerUserMenu/UserMenu.d.ts +11 -0
- package/dist/components/headerUserMenu/UserMenu.test.d.ts +0 -0
- package/dist/components/heading/Heading.d.ts +14 -0
- package/dist/components/heading/Heading.test.d.ts +0 -0
- package/dist/components/helptext/Helptext.d.ts +9 -0
- package/dist/components/helptext/Helptext.test.d.ts +0 -0
- package/dist/components/icon/Icon.d.ts +10 -0
- package/dist/components/icon/Icon.test.d.ts +9 -0
- package/dist/components/index.d.ts +50 -0
- package/dist/components/input/Input.d.ts +21 -0
- package/dist/components/inputwrapper/InputWrapper.d.ts +28 -0
- package/dist/components/interfaces.d.ts +30 -0
- package/dist/components/link/Link.d.ts +17 -0
- package/dist/components/link/Link.test.d.ts +1 -0
- package/dist/components/linkcard/LinkCard.d.ts +14 -0
- package/dist/components/linkcard/LinkCard.test.d.ts +0 -0
- package/dist/components/loader/Loader.d.ts +41 -0
- package/dist/components/loader/Loader.test.d.ts +0 -0
- package/dist/components/messagebox/Messagebox.d.ts +11 -0
- package/dist/components/messagebox/Messagebox.test.d.ts +1 -0
- package/dist/components/modal/Modal.d.ts +17 -0
- package/dist/components/modal/Modal.test.d.ts +0 -0
- package/dist/components/progressbar/Progressbar.d.ts +21 -0
- package/dist/components/progressbar/Progressbar.test.d.ts +0 -0
- package/dist/components/radio/RadioButton.d.ts +20 -0
- package/dist/components/radio/RadioButton.test.d.ts +0 -0
- package/dist/components/searchinput/SearchInput.d.ts +36 -0
- package/dist/components/searchinput/SearchInput.test.d.ts +0 -0
- package/dist/components/select/Select.d.ts +30 -0
- package/dist/components/select/Select.test.d.ts +0 -0
- package/dist/components/stepper/Step.d.ts +21 -0
- package/dist/components/stepper/Stepper.d.ts +32 -0
- package/dist/components/stepper/Stepper.test.d.ts +0 -0
- package/dist/components/table/Table.d.ts +11 -0
- package/dist/components/table/Table.test.d.ts +0 -0
- package/dist/components/table/TableBody.d.ts +7 -0
- package/dist/components/table/TableData.d.ts +7 -0
- package/dist/components/table/TableDataCell.d.ts +8 -0
- package/dist/components/table/TableHeader.d.ts +7 -0
- package/dist/components/table/TableHeaderCell.d.ts +7 -0
- package/dist/components/table/TableRow.d.ts +7 -0
- package/dist/components/tabs/TabItem.d.ts +15 -0
- package/dist/components/tabs/Tabs.d.ts +33 -0
- package/dist/components/tabs/Tabs.test.d.ts +0 -0
- package/dist/components/tag/Tag.d.ts +24 -0
- package/dist/components/tag/Tag.test.d.ts +0 -0
- package/dist/components/textarea/Textarea.d.ts +35 -0
- package/dist/components/textarea/Textarea.test.d.ts +0 -0
- package/dist/components/textinput/Textinput.d.ts +44 -0
- package/dist/components/textinput/Textinput.test.d.ts +0 -0
- package/dist/components/timepicker/Timepicker.d.ts +3 -0
- package/dist/components/timepicker/Timepicker.test.d.ts +0 -0
- package/dist/components/timepicker/types.d.ts +81 -0
- package/dist/components/timepicker/useTimepickerState.d.ts +58 -0
- package/dist/components/types.d.ts +2 -0
- package/dist/index.d.ts +1 -1366
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +698 -684
- package/package.json +33 -32
- package/src/components/calendar/types.ts +1 -1
- package/src/components/card/Card.tsx +1 -1
- package/src/components/combobox/types.ts +5 -5
- package/src/components/datepicker/types.ts +5 -5
- package/src/components/fileupload/FileUpload.tsx +1 -1
- package/src/components/fileupload/Subcomponents.tsx +1 -1
- package/src/components/fileupload/Truncate.tsx +1 -1
- package/src/components/fileupload/hooks/useRequiredFormValidation.ts +1 -1
- package/src/components/header/HeaderService.tsx +1 -1
- package/src/components/tabs/Tabs.tsx +1 -0
- package/src/components/tag/Tag.tsx +1 -1
- package/src/components/timepicker/Timepicker.tsx +1 -2
- package/src/components/timepicker/types.ts +2 -5
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export declare const consentStrings: {
|
|
2
|
+
i18n: {
|
|
3
|
+
nb: {
|
|
4
|
+
contentPresentation: {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string[];
|
|
7
|
+
buttons: {
|
|
8
|
+
accept: string;
|
|
9
|
+
reject: string;
|
|
10
|
+
settings: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
contentSettings: {
|
|
14
|
+
title: string;
|
|
15
|
+
description: string[];
|
|
16
|
+
buttons: {
|
|
17
|
+
back: string;
|
|
18
|
+
save: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
en: {
|
|
23
|
+
contentPresentation: {
|
|
24
|
+
title: string;
|
|
25
|
+
description: string[];
|
|
26
|
+
buttons: {
|
|
27
|
+
accept: string;
|
|
28
|
+
reject: string;
|
|
29
|
+
settings: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
contentSettings: {
|
|
33
|
+
title: string;
|
|
34
|
+
description: string[];
|
|
35
|
+
buttons: {
|
|
36
|
+
back: string;
|
|
37
|
+
save: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
cookies: ({
|
|
43
|
+
name: string;
|
|
44
|
+
defaultValue: null;
|
|
45
|
+
i18n: {
|
|
46
|
+
nb: {
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
buttons: {
|
|
50
|
+
yes: string;
|
|
51
|
+
no: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
en: {
|
|
55
|
+
title: string;
|
|
56
|
+
description: string;
|
|
57
|
+
buttons: {
|
|
58
|
+
yes: string;
|
|
59
|
+
no: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
name: string;
|
|
65
|
+
defaultValue: boolean;
|
|
66
|
+
i18n: {
|
|
67
|
+
nb: {
|
|
68
|
+
title: string;
|
|
69
|
+
description: string;
|
|
70
|
+
buttons: {
|
|
71
|
+
yes: string;
|
|
72
|
+
no: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
en: {
|
|
76
|
+
title: string;
|
|
77
|
+
description: string;
|
|
78
|
+
buttons: {
|
|
79
|
+
yes: string;
|
|
80
|
+
no: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
})[];
|
|
85
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDatepickerStrings } from '../../shared-types/datepicker';
|
|
2
|
+
interface DateTagsProps {
|
|
3
|
+
dates: string[];
|
|
4
|
+
dateformat: string;
|
|
5
|
+
idBase: string;
|
|
6
|
+
strings?: IDatepickerStrings;
|
|
7
|
+
onDateRemoved: (date: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const DateTags: ({ dates, dateformat, idBase, strings, onDateRemoved, }: DateTagsProps) => import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface DatepickerPopupProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
multiple?: boolean;
|
|
4
|
+
range?: boolean;
|
|
5
|
+
weeknumbers?: boolean;
|
|
6
|
+
withcontrols?: boolean;
|
|
7
|
+
selected?: string[];
|
|
8
|
+
earliest?: string | null;
|
|
9
|
+
latest?: string | null;
|
|
10
|
+
excludedates?: string[];
|
|
11
|
+
excludeweekdays?: string[];
|
|
12
|
+
maxMultiple?: number;
|
|
13
|
+
currentmonth?: string | null;
|
|
14
|
+
today?: string;
|
|
15
|
+
inputRef?: React.RefObject<HTMLInputElement | null>;
|
|
16
|
+
hasCounter?: boolean;
|
|
17
|
+
onDateSelected: (selected: string[]) => void;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare const DatepickerPopup: ({ open, multiple, range, weeknumbers, withcontrols, selected, earliest, latest, excludedates, excludeweekdays, maxMultiple, currentmonth, today, inputRef, hasCounter, onDateSelected, onClose, }: DatepickerPopupProps) => import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ChangeEvent, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { IDatepickerStrings } from '../../shared-types/datepicker';
|
|
3
|
+
export interface IPktDatepicker extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
value?: string | string[];
|
|
7
|
+
dateformat?: string;
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
maxlength?: number;
|
|
10
|
+
range?: boolean;
|
|
11
|
+
showRangeLabels?: boolean;
|
|
12
|
+
weeknumbers?: boolean;
|
|
13
|
+
withcontrols?: boolean;
|
|
14
|
+
excludedates?: string[];
|
|
15
|
+
excludeweekdays?: string[];
|
|
16
|
+
currentmonth?: string;
|
|
17
|
+
today?: string;
|
|
18
|
+
calendarOpen?: boolean;
|
|
19
|
+
timezone?: string;
|
|
20
|
+
fullwidth?: boolean;
|
|
21
|
+
hasFieldset?: boolean;
|
|
22
|
+
inline?: boolean;
|
|
23
|
+
helptext?: string | ReactNode;
|
|
24
|
+
helptextDropdown?: string | ReactNode;
|
|
25
|
+
helptextDropdownButton?: string;
|
|
26
|
+
hasError?: boolean;
|
|
27
|
+
errorMessage?: string | ReactNode;
|
|
28
|
+
optionalTag?: boolean;
|
|
29
|
+
optionalText?: string;
|
|
30
|
+
requiredTag?: boolean;
|
|
31
|
+
requiredText?: string;
|
|
32
|
+
tagText?: string;
|
|
33
|
+
useWrapper?: boolean;
|
|
34
|
+
strings?: IDatepickerStrings;
|
|
35
|
+
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
36
|
+
onValueChange?: (values: string[]) => void;
|
|
37
|
+
className?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface IDatepickerState {
|
|
40
|
+
id: string;
|
|
41
|
+
inputId: string;
|
|
42
|
+
values: string[];
|
|
43
|
+
calendarOpen: boolean;
|
|
44
|
+
label: string;
|
|
45
|
+
dateformat: string;
|
|
46
|
+
multiple: boolean;
|
|
47
|
+
maxlength?: number;
|
|
48
|
+
range: boolean;
|
|
49
|
+
showRangeLabels: boolean;
|
|
50
|
+
weeknumbers: boolean;
|
|
51
|
+
withcontrols: boolean;
|
|
52
|
+
excludedates?: string[];
|
|
53
|
+
excludeweekdays?: string[];
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
readOnly: boolean;
|
|
56
|
+
required: boolean;
|
|
57
|
+
name?: string;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
fullwidth: boolean;
|
|
60
|
+
hasFieldset: boolean;
|
|
61
|
+
inline: boolean;
|
|
62
|
+
helptext?: string | ReactNode;
|
|
63
|
+
helptextDropdown?: string | ReactNode;
|
|
64
|
+
helptextDropdownButton?: string;
|
|
65
|
+
hasError: boolean;
|
|
66
|
+
errorMessage?: string | ReactNode;
|
|
67
|
+
optionalTag: boolean;
|
|
68
|
+
optionalText?: string;
|
|
69
|
+
requiredTag: boolean;
|
|
70
|
+
requiredText?: string;
|
|
71
|
+
tagText?: string;
|
|
72
|
+
useWrapper: boolean;
|
|
73
|
+
className?: string;
|
|
74
|
+
minStr?: string;
|
|
75
|
+
maxStr?: string;
|
|
76
|
+
effectiveCurrentMonth?: string;
|
|
77
|
+
today?: string;
|
|
78
|
+
inputType: string;
|
|
79
|
+
isIOSDevice: boolean;
|
|
80
|
+
strings: IDatepickerStrings;
|
|
81
|
+
inputClasses: string;
|
|
82
|
+
buttonClasses: string;
|
|
83
|
+
rangeLabelClasses: string;
|
|
84
|
+
datepickerInputsClasses: string;
|
|
85
|
+
isInputDisabled: boolean;
|
|
86
|
+
hasCounter: boolean;
|
|
87
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
88
|
+
inputRefTo: React.RefObject<HTMLInputElement | null>;
|
|
89
|
+
changeInputRef: React.RefObject<HTMLInputElement | null>;
|
|
90
|
+
btnRef: React.RefObject<HTMLButtonElement | null>;
|
|
91
|
+
wrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
92
|
+
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
93
|
+
toggleCalendar: () => void;
|
|
94
|
+
hideCalendar: () => void;
|
|
95
|
+
handleDateSelected: (selected: string[]) => void;
|
|
96
|
+
handleCalendarClose: () => void;
|
|
97
|
+
handleFocus: () => void;
|
|
98
|
+
handleSingleInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
99
|
+
handleRangeFromChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
100
|
+
handleRangeToChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
101
|
+
handleRangeBlur: () => void;
|
|
102
|
+
handleMultipleBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
103
|
+
handleTagRemoved: (date: string) => void;
|
|
104
|
+
handleSingleKeydown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
105
|
+
handleRangeFromKeydown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
106
|
+
handleRangeToKeydown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
107
|
+
handleMultipleKeydown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
108
|
+
restProps: Record<string, unknown>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import { TFileItemList, TUploadStrategy } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the internal `DropZone` building block.
|
|
5
|
+
*
|
|
6
|
+
* This component is responsible for:
|
|
7
|
+
* - rendering the native `<input type="file">` (visually hidden, still accessible)
|
|
8
|
+
* - handling drag & drop + file dialog selection
|
|
9
|
+
* - optionally rendering hidden inputs with file IDs when `uploadStrategy="custom"`
|
|
10
|
+
*/
|
|
11
|
+
interface IDropZoneProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width'> {
|
|
12
|
+
/** Called with `FileItem`s created from dropped/selected files. */
|
|
13
|
+
onFilesAdded?: (files: TFileItemList) => void;
|
|
14
|
+
/** Used for the native input `id` and related label/ARIA wiring. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Allow selecting/dropping multiple files. */
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
/** Current file list (used for custom hidden inputs + re-populating the native input). */
|
|
19
|
+
value: TFileItemList;
|
|
20
|
+
/**
|
|
21
|
+
* Field name.
|
|
22
|
+
* - `uploadStrategy="form"`: used as `<input name="...">` so the files are posted on submit.
|
|
23
|
+
* - `uploadStrategy="custom"`: used for hidden `<input type="hidden" name="...">` file IDs.
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/** Upload mode. */
|
|
27
|
+
uploadStrategy: TUploadStrategy;
|
|
28
|
+
/** Enables alternate texts/UX for thumbnail view. */
|
|
29
|
+
isThumbnailView?: boolean;
|
|
30
|
+
/** Disables all interaction. */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** Whether the file input already has an external visible label associated with it. */
|
|
33
|
+
hasVisibleLabel?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const DropZone: import('react').ForwardRefExoticComponent<IDropZoneProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a `FileList` from a list of `FileItem`s.
|
|
38
|
+
*
|
|
39
|
+
* Note: relies on `DataTransfer`, which may be missing or restricted in test environments (jsdom).
|
|
40
|
+
*/
|
|
41
|
+
export declare const createFileList: (fileItemList: TFileItemList) => FileList;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { FC, HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ItemRenderers } from './QueueDisplay';
|
|
3
|
+
import { FileItem, TFileItemList, TFileTransfer, TFileValidateDetail, TItemRenderer, TQueueItemOperation, TUploadStrategy } from './types';
|
|
4
|
+
export { formatFileSize, parseFileSize } from '../../shared-utils/fileupload';
|
|
5
|
+
/**
|
|
6
|
+
* Shared props for `PktFileUpload` (both `form` and `custom` strategies).
|
|
7
|
+
*/
|
|
8
|
+
interface IBaseFileUploadProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width' | 'defaultValue'> {
|
|
9
|
+
/** Called with the next file list when files are added/removed/updated. */
|
|
10
|
+
onFilesChanged?: (files: TFileItemList) => void;
|
|
11
|
+
/** Allow selecting/dropping multiple files. */
|
|
12
|
+
multiple?: boolean;
|
|
13
|
+
/** Controlled value (recommended). */
|
|
14
|
+
value?: TFileItemList;
|
|
15
|
+
/** Upload mode. Defaults to `"form"`. */
|
|
16
|
+
uploadStrategy?: TUploadStrategy;
|
|
17
|
+
/** Field name. Used for native input (`form`) or hidden ID inputs (`custom`). */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Enable comment operation (disabled automatically in thumbnail view). */
|
|
20
|
+
addCommentsEnabled?: boolean;
|
|
21
|
+
/** Enable rename operation (disabled automatically in thumbnail view). */
|
|
22
|
+
renameFilesEnabled?: boolean;
|
|
23
|
+
/** Renderer for queue items (`filename`, `thumbnail`, or custom function). */
|
|
24
|
+
itemRenderer?: keyof typeof ItemRenderers | TItemRenderer;
|
|
25
|
+
/** Number of trailing characters to keep when truncating long filenames. */
|
|
26
|
+
truncateTail?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Called immediately when a file is added in `uploadStrategy="custom"`.
|
|
29
|
+
* Use it to start uploading the file and update `transfers`.
|
|
30
|
+
*/
|
|
31
|
+
onFileUploadRequested?: (fileItem: FileItem) => void;
|
|
32
|
+
/** Uncontrolled initial value (use either `value` or `defaultValue`, not both). */
|
|
33
|
+
defaultValue?: TFileItemList;
|
|
34
|
+
/** Extra operations appended after built-ins (rename/comment). */
|
|
35
|
+
extraOperations?: Array<TQueueItemOperation>;
|
|
36
|
+
/** Stretch to full container width (drop zone + queue). */
|
|
37
|
+
fullwidth?: boolean;
|
|
38
|
+
/** Allowed formats for built-in validation (extensions like `pdf`, or MIME patterns like `image/*`). */
|
|
39
|
+
allowedFormats?: string[];
|
|
40
|
+
/** Custom message for invalid format. Use `{formats}` placeholder. */
|
|
41
|
+
formatErrorMessage?: string;
|
|
42
|
+
/** Max file size (e.g. `"5MB"` or bytes). */
|
|
43
|
+
maxFileSize?: string | number;
|
|
44
|
+
/** Custom message for size validation. Use `{maxSize}` placeholder. */
|
|
45
|
+
sizeErrorMessage?: string;
|
|
46
|
+
/** Optional additional validation hook (runs after built-in format/size checks). Return string to block. */
|
|
47
|
+
onFileValidation?: (file: File) => string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Low-level validation escape hatch — Lit parity with the `file-validate` CustomEvent.
|
|
50
|
+
* Receives a detail object whose `errorMessage` can be mutated; set it to reject the file.
|
|
51
|
+
*/
|
|
52
|
+
onFileValidate?: (detail: TFileValidateDetail) => void;
|
|
53
|
+
/** External/programmatic error message shown under the component. */
|
|
54
|
+
errorMessage?: string;
|
|
55
|
+
/** External error flag (combined with internal validation errors). */
|
|
56
|
+
hasError?: boolean;
|
|
57
|
+
/** Disable the whole component (no interaction). */
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
/** Optional label/title (wraps the component in `PktInputWrapper`). */
|
|
60
|
+
label?: string;
|
|
61
|
+
/** Help text under the label. */
|
|
62
|
+
helptext?: string | ReactNode;
|
|
63
|
+
/** Show "Valgfritt" tag in wrapper. */
|
|
64
|
+
optionalTag?: boolean;
|
|
65
|
+
/** Show "Må fylles ut" tag in wrapper. */
|
|
66
|
+
requiredTag?: boolean;
|
|
67
|
+
/** Marks the upload as required. Native validation is used in `form`; submit validation in `custom`. */
|
|
68
|
+
required?: boolean;
|
|
69
|
+
/** Enable image preview modal (only applies to thumbnail renderer). */
|
|
70
|
+
enableImagePreview?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface IFileInputFileUploadProps extends IBaseFileUploadProps, Omit<HTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'> {
|
|
73
|
+
uploadStrategy?: 'form';
|
|
74
|
+
onFileUploadRequested?: never;
|
|
75
|
+
}
|
|
76
|
+
interface ImmediateFileUploadProps extends IBaseFileUploadProps {
|
|
77
|
+
id: string;
|
|
78
|
+
uploadStrategy: 'custom';
|
|
79
|
+
transfers: Array<TFileTransfer>;
|
|
80
|
+
onFileUploadRequested: (fileItem: FileItem) => void;
|
|
81
|
+
onTransferCancelled?: (fileItemId: string) => void;
|
|
82
|
+
}
|
|
83
|
+
export type IPktFileUpload = IFileInputFileUploadProps | ImmediateFileUploadProps;
|
|
84
|
+
export declare const PktFileUpload: FC<IPktFileUpload>;
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { getProgressState } from './QueueItemContent';
|
|
3
|
+
import { TFileId, TFileItemList, TFileTransfer, TItemRenderer, TQueueItemOperation, TQueueOperationContext } from './types';
|
|
4
|
+
interface IQueueDisplay {
|
|
5
|
+
cancelTransfer: (fileItemId: string) => void;
|
|
6
|
+
transfers?: TFileTransfer[];
|
|
7
|
+
files: TFileItemList;
|
|
8
|
+
queueItemOperations?: TQueueItemOperation[];
|
|
9
|
+
ItemRenderer?: TItemRenderer;
|
|
10
|
+
truncateTail?: number;
|
|
11
|
+
enableImagePreview?: boolean;
|
|
12
|
+
uploadStrategy?: 'form' | 'custom';
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
inputName: string;
|
|
15
|
+
buildAttributeAccessors: (fileId: TFileId) => Pick<TQueueOperationContext, 'getAttribute' | 'setAttribute'>;
|
|
16
|
+
}
|
|
17
|
+
export declare const QueueDisplay: FC<IQueueDisplay>;
|
|
18
|
+
export { getProgressState };
|
|
19
|
+
export declare const ItemRenderers: Record<string, TItemRenderer>;
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TProgressState } from '../../shared-utils/fileupload';
|
|
3
|
+
import { TFileAndTransfer, TFileId, TItemRenderer, TQueueItemOperation, TQueueOperationContext } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Re-export so that external consumers who imported `getProgressState` from
|
|
6
|
+
* this module keep working. Internal code should prefer the shared import.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getProgressState: (progress: TFileAndTransfer["progress"]) => TProgressState;
|
|
9
|
+
/** Build a stable `TQueueOperationContext` for the given file + operation pair. */
|
|
10
|
+
export declare const buildOperationContext: ({ operation, transferItem, inputName, disabled, activatedOperation, onActivate, onClose, buildAttributeAccessors, }: {
|
|
11
|
+
operation: TQueueItemOperation;
|
|
12
|
+
transferItem: TFileAndTransfer;
|
|
13
|
+
inputName: string;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
activatedOperation?: TQueueItemOperation;
|
|
16
|
+
onActivate: (fileId: TFileId, operation: TQueueItemOperation) => void;
|
|
17
|
+
onClose: (fileId: TFileId) => void;
|
|
18
|
+
buildAttributeAccessors: (fileId: TFileId) => Pick<TQueueOperationContext, "getAttribute" | "setAttribute">;
|
|
19
|
+
}) => TQueueOperationContext;
|
|
20
|
+
interface ICommonContentProps {
|
|
21
|
+
transferItem: TFileAndTransfer;
|
|
22
|
+
operations: TQueueItemOperation[];
|
|
23
|
+
activatedOperation?: TQueueItemOperation;
|
|
24
|
+
inputName: string;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
onActivate: (fileId: TFileId, operation: TQueueItemOperation) => void;
|
|
27
|
+
onClose: (fileId: TFileId) => void;
|
|
28
|
+
buildAttributeAccessors: (fileId: TFileId) => Pick<TQueueOperationContext, 'getAttribute' | 'setAttribute'>;
|
|
29
|
+
}
|
|
30
|
+
export declare const OperationActions: FC<ICommonContentProps>;
|
|
31
|
+
export declare const OperationContents: FC<ICommonContentProps>;
|
|
32
|
+
interface IIdleStateContent extends ICommonContentProps {
|
|
33
|
+
ItemRenderer: TItemRenderer;
|
|
34
|
+
onPreviewClick?: () => void;
|
|
35
|
+
}
|
|
36
|
+
export declare const IdleStateContent: FC<IIdleStateContent>;
|
|
37
|
+
interface IQueueItemContent extends ICommonContentProps {
|
|
38
|
+
ItemRenderer: TItemRenderer;
|
|
39
|
+
enableImagePreview: boolean;
|
|
40
|
+
onCancelTransfer: (fileId: string) => void;
|
|
41
|
+
onOpenPreview: (fileId: TFileId) => void;
|
|
42
|
+
}
|
|
43
|
+
export declare const QueueItemContent: FC<IQueueItemContent>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { TFileAndTransfer, TQueueItemOperation, TQueueOperationContext, TTransferItemInProgress } from './types';
|
|
3
|
+
export declare const TransferInProgress: ({ cancelTransfer, transferItem, disabled, }: {
|
|
4
|
+
transferItem: TTransferItemInProgress;
|
|
5
|
+
cancelTransfer: () => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}) => import("react").JSX.Element;
|
|
8
|
+
export declare const TransferError: ({ transferItem, onRemove, disabled, }: {
|
|
9
|
+
transferItem: TFileAndTransfer;
|
|
10
|
+
onRemove: () => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
13
|
+
export declare const OperationButton: ({ operation, context, }: {
|
|
14
|
+
operation: TQueueItemOperation;
|
|
15
|
+
context: TQueueOperationContext;
|
|
16
|
+
}) => import("react").JSX.Element | null;
|
|
17
|
+
export declare const FilenameRenderer: ({ transferItem, }: {
|
|
18
|
+
transferItem: TFileAndTransfer;
|
|
19
|
+
queueItemOperations?: Array<TQueueItemOperation>;
|
|
20
|
+
onPreviewClick?: () => void;
|
|
21
|
+
}) => import("react").JSX.Element;
|
|
22
|
+
export declare const ThumbnailRenderer: ({ transferItem, onPreviewClick, }: {
|
|
23
|
+
transferItem: TFileAndTransfer;
|
|
24
|
+
queueItemOperations?: Array<TQueueItemOperation>;
|
|
25
|
+
onPreviewClick?: () => void;
|
|
26
|
+
}) => import("react").JSX.Element;
|
|
27
|
+
interface IImagePreviewModal {
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
images: TFileAndTransfer[];
|
|
30
|
+
currentIndex: number;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
onNavigate: (direction: 'prev' | 'next') => void;
|
|
33
|
+
modalRef: RefObject<HTMLDialogElement | null>;
|
|
34
|
+
}
|
|
35
|
+
export declare const ImagePreviewModal: ({ isOpen, images, currentIndex, onClose, onNavigate, modalRef, }: IImagePreviewModal) => import("react").JSX.Element | null;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
export interface IMiddleTruncate {
|
|
3
|
+
children: string;
|
|
4
|
+
/** Trailing chars to preserve when the name is long enough to split. */
|
|
5
|
+
tail?: number;
|
|
6
|
+
}
|
|
7
|
+
type TTruncateContext = {
|
|
8
|
+
tail: number | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const TruncateContext: import('react').Context<TTruncateContext>;
|
|
11
|
+
/**
|
|
12
|
+
* Middle-truncate a filename. Renders as a React fragment — the parent element
|
|
13
|
+
* (typically a `<p className="…__title">`) is the grid container that drives
|
|
14
|
+
* the layout via CSS in `_fileupload.scss`. The split threshold is shared with
|
|
15
|
+
* the Lit implementation through `splitFilenameForTruncation`.
|
|
16
|
+
*
|
|
17
|
+
* For short filenames the tail span is omitted and the text renders unwrapped.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Truncate: ({ children, tail: tailProp }: IMiddleTruncate) => JSX.Element;
|
|
20
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileItem, TFileAttributes, TFileId, TFileItemList, TQueueOperationContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Build accessors that let queue-item operations read and write per-file
|
|
4
|
+
* attributes without ever mutating the current `value` list. All changes are
|
|
5
|
+
* propagated via `onFileUpdated`, so controlled parents stay authoritative.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useFileAttributes: (value: TFileItemList, onFileUpdated: (fileId: TFileId, updates: Partial<FileItem>) => void) => {
|
|
8
|
+
readonly fileAttributes: TFileAttributes;
|
|
9
|
+
readonly buildAttributeAccessors: (fileId: TFileId) => Pick<TQueueOperationContext, "getAttribute" | "setAttribute">;
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TFileAndTransfer, TFileId } from '../types';
|
|
2
|
+
export declare const useImagePreview: (previewableImages: TFileAndTransfer[]) => {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
currentIndex: number;
|
|
5
|
+
modalRef: import('react').RefObject<HTMLDialogElement | null>;
|
|
6
|
+
open: (fileId: TFileId) => void;
|
|
7
|
+
close: () => void;
|
|
8
|
+
navigate: (direction: "prev" | "next") => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TFileId, TQueueItemOperation } from '../types';
|
|
2
|
+
export declare const useOperationState: (queueItemOperations: TQueueItemOperation[]) => {
|
|
3
|
+
getActivated: (fileId: TFileId) => TQueueItemOperation | undefined;
|
|
4
|
+
activate: (fileId: TFileId, operation: TQueueItemOperation) => void;
|
|
5
|
+
close: (fileId: TFileId) => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* When `uploadStrategy="custom"` and the upload is marked `required`, the
|
|
4
|
+
* native `required` attribute can't do the work (the input isn't posted).
|
|
5
|
+
* This hook attaches a submit listener to the containing `<form>` that
|
|
6
|
+
* prevents submission if the queue is empty, and surfaces a validation
|
|
7
|
+
* error via `onMissingFiles`.
|
|
8
|
+
*
|
|
9
|
+
* Passive in `form` strategy — native validation handles that case.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useRequiredFormValidation: (fileInputRef: RefObject<HTMLInputElement | null>, { uploadStrategy, required, currentFileCount, onMissingFiles, }: {
|
|
12
|
+
uploadStrategy: "form" | "custom";
|
|
13
|
+
required: boolean;
|
|
14
|
+
currentFileCount: number;
|
|
15
|
+
onMissingFiles: () => void;
|
|
16
|
+
}) => void;
|