@arbeidstilsynet/design-react 0.0.16 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import { FilePickerProps } from './types';
2
+ export declare function FilePicker<TFileId extends string | number>({ ref, className, children, disabled, isWaiting, files, errors, onAdd, onRemove, ...rest }: Readonly<FilePickerProps<TFileId>>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { FilePicker } from '..';
3
+ declare const meta: Meta<typeof FilePicker>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Preview: Story;
7
+ export declare const WithErrors: Story;
8
+ export declare const Disabled: Story;
9
+ export declare const ChangedDefaultText: Story;
10
+ export declare const IsWaiting: Story;
11
+ export declare const SideBySide: Story;
@@ -0,0 +1,3 @@
1
+ import { FilePickerProps } from './types';
2
+ export type FilePickerContextValue<TFileId extends string | number> = Pick<FilePickerProps<TFileId>, "files" | "errors" | "disabled" | "isWaiting" | "onAdd" | "onRemove">;
3
+ export declare const FilePickerContext: React.Context<FilePickerContextValue<string | number>>;
@@ -0,0 +1,15 @@
1
+ import { ButtonProps } from '../../digdir';
2
+ import { DefaultProps } from '../../types';
3
+ export interface FilePickerDropzoneProps extends DefaultProps<HTMLButtonElement>, Omit<ButtonProps, "children" | "asChild" | "variant" | "type" | "icon"> {
4
+ /** Replace the default label nodes. Should use `<Label>` or other typography. */
5
+ label?: React.ReactNode;
6
+ /**
7
+ * Replace the text in default label.
8
+ * Pass an array with one or two strings.
9
+ * If only one is passed, the second line is not displayed.
10
+ * */
11
+ defaultLabelText?: [string] | [string, string];
12
+ /** Label text shown when a file is dragged over the dropzone */
13
+ dropLabel?: string;
14
+ }
15
+ export declare function FilePickerDropzone({ className, label, defaultLabelText, dropLabel, ...rest }: Readonly<FilePickerDropzoneProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { DefaultProps } from '../../types';
3
+ export interface FilePickerErrorsProps extends DefaultProps<HTMLDivElement>, HTMLAttributes<HTMLDivElement> {
4
+ }
5
+ export declare function FilePickerErrors({ className, ...rest }: FilePickerErrorsProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,5 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { DefaultProps } from '../../types';
3
+ export interface FilePickerFilesProps extends DefaultProps<HTMLDivElement>, HTMLAttributes<HTMLDivElement> {
4
+ }
5
+ export declare function FilePickerFiles({ className, ...rest }: Readonly<FilePickerFilesProps>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,34 @@
1
+ import { FilePicker as FilePickerParent } from './filepicker';
2
+ import { FilePickerDropzone } from './filepickerDropzone';
3
+ import { FilePickerErrors } from './filepickerErrors';
4
+ import { FilePickerFiles } from './filepickerFiles';
5
+ /**
6
+ * Controlled component for managing file uploads.
7
+ * You should perform validation in `onAdd`/`onRemove` callbacks and pass a list of errors in props.
8
+ *
9
+ * Uses [react-dropzone](https://react-dropzone.js.org/) for drag-and-drop functionality.
10
+ *
11
+ * Note: the default label text is only an example. File types are not enforced by the component, but can be done in your validation logic as needed.
12
+ *
13
+ * FilePicker has no internal state and can be fully controlled as needed with a combination of `files`, `errors`, `disabled`, `isWaiting` props as well as using the subcomponents as desired. For example, you can change the order of the sucomponents or only use some of them. You decide if the `files` prop only contains accepted files or all including errors, and you can use the `errors` prop to display validation errors in your UI.
14
+ *
15
+ * Usage:
16
+ * ```tsx
17
+ * <FilePicker files={files} errors={errors} onAdd={handleAddFiles} onRemove={handleRemoveFile}>
18
+ * <FilePicker.Dropzone defaultLabelText={["Upload here!"]} />
19
+ * <FilePicker.Files />
20
+ * <FilePicker.Errors />
21
+ * </FilePicker>
22
+ * ```
23
+ */
24
+ declare const FilePicker: typeof FilePickerParent & {
25
+ Dropzone: typeof FilePickerDropzone;
26
+ Files: typeof FilePickerFiles;
27
+ Errors: typeof FilePickerErrors;
28
+ };
29
+ export { FilePickerContext } from './filepickerContext';
30
+ export type { FilePickerDropzoneProps } from './filepickerDropzone';
31
+ export type { FilePickerErrorsProps } from './filepickerErrors';
32
+ export type { FilePickerFilesProps } from './filepickerFiles';
33
+ export type { FilePickerItem, FilePickerProps } from './types';
34
+ export { FilePicker, FilePickerDropzone, FilePickerErrors, FilePickerFiles };
@@ -0,0 +1,27 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { DefaultProps } from '../../types';
3
+ export interface FilePickerProps<TFileId extends string | number> extends DefaultProps<HTMLDivElement>, HTMLAttributes<HTMLDivElement> {
4
+ /** Should the FilePicker be disabled */
5
+ disabled?: boolean;
6
+ /** Display spinner while processing files */
7
+ isWaiting?: boolean;
8
+ /** List of currently selected files
9
+ *
10
+ * https://developer.mozilla.org/en-US/docs/Web/API/File
11
+ */
12
+ files: FilePickerItem<TFileId>[] | null;
13
+ /** List of general validation errors. Will be displayed by `FilePicker.Errors` */
14
+ errors: string[] | null;
15
+ /** Function to call when adding one or more files */
16
+ onAdd: (files: File[]) => void | Promise<void>;
17
+ /** Function called when removing a file */
18
+ onRemove: (id: TFileId) => void | Promise<void>;
19
+ }
20
+ export interface FilePickerItem<TFileId extends string | number = string | number> {
21
+ /** Id for this file. Used as React key. Should be unique. You can use `file.name` if you prevent duplicates. */
22
+ id: TFileId;
23
+ /** The file itself. See: https://developer.mozilla.org/en-US/docs/Web/API/File */
24
+ file: File;
25
+ /** Validation error for this file. Will be displayed on the file in `FilePicker.Files`. */
26
+ error?: string | null;
27
+ }
@@ -0,0 +1,3 @@
1
+ export declare function createMockFile(name: string, sizeInBytes: number, type?: string): File;
2
+ export declare function createMockFileInKb(name: string, sizeInKB: number, type?: string): File;
3
+ export declare function formatFileSize(bytes: number): string;
@@ -1 +1,2 @@
1
+ export * from './filepicker';
1
2
  export * from './temp-example';
@@ -0,0 +1,2 @@
1
+ export type * from '@digdir/designsystemet-react';
2
+ export { Alert, Avatar, Badge, BadgePosition, Breadcrumbs, BreadcrumbsItem, BreadcrumbsLink, BreadcrumbsList, Button, Card, CardBlock, Checkbox, Chip, ChipButton, ChipCheckbox, ChipRadio, ChipRemovable, Combobox, ComboboxEmpty, ComboboxOption, Details, DetailsContent, DetailsSummary, Dialog, DialogBlock, DialogTrigger, DialogTriggerContext, Divider, Dropdown, DropdownButton, DropdownHeading, DropdownItem, DropdownList, DropdownTrigger, DropdownTriggerContext, ErrorSummary, ErrorSummaryHeading, ErrorSummaryItem, ErrorSummaryLink, ErrorSummaryList, EXPERIMENTAL_Suggestion, EXPERIMENTAL_SuggestionClear, EXPERIMENTAL_SuggestionEmpty, EXPERIMENTAL_SuggestionInput, EXPERIMENTAL_SuggestionList, EXPERIMENTAL_SuggestionOption, Field, FieldAffix, FieldAffixes, FieldCounter, FieldDescription, Fieldset, FieldsetDescription, FieldsetLegend, getNextFocusableValue, getPrevFocusableValue, Heading, Input, Label, Link, List, ListItem, ListOrdered, ListUnordered, omit, Pagination, PaginationButton, PaginationItem, PaginationList, Paragraph, Popover, PopoverTrigger, PopoverTriggerContext, Radio, RovingFocusItem, RovingFocusRoot, Search, SearchButton, SearchClear, SearchInput, Select, SelectOptgroup, SelectOption, Skeleton, SkipLink, Spinner, Switch, Table, TableBody, TableCell, TableFoot, TableHead, TableHeaderCell, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Tag, Textarea, Textfield, ToggleGroup, ToggleGroupItem, Tooltip, useCheckboxGroup, useDebounceCallback, useIsomorphicLayoutEffect, useMediaQuery, usePagination, useRadioGroup, useRovingFocus, useSynchronizedAnimation, ValidationMessage, } from '@digdir/designsystemet-react';
package/dist/index.cjs CHANGED
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const designsystemetReact = require("@digdir/designsystemet-react");
5
4
  const require$$0 = require("react");
5
+ const akselIcons = require("@navikt/aksel-icons");
6
+ const reactDropzone = require("react-dropzone");
7
+ const designsystemetReact = require("@digdir/designsystemet-react");
6
8
  var jsxRuntime = { exports: {} };
7
9
  var reactJsxRuntime_production = {};
8
10
  /**
@@ -383,6 +385,475 @@ function requireCompilerRuntime() {
383
385
  return compilerRuntime.exports;
384
386
  }
385
387
  var compilerRuntimeExports = requireCompilerRuntime();
388
+ function clsx() {
389
+ for (var t, r = 0, e = "", n = arguments.length; r < n; r++) (t = arguments[r]) && "string" == typeof t && (e += (e && " ") + t);
390
+ return e;
391
+ }
392
+ const FilePickerContext = require$$0.createContext({
393
+ files: [],
394
+ errors: null,
395
+ onAdd: () => {
396
+ throw new TypeError("FilePickerContext is missing");
397
+ },
398
+ onRemove: () => {
399
+ throw new TypeError("FilePickerContext is missing");
400
+ }
401
+ });
402
+ function FilePicker$1(t0) {
403
+ const $ = compilerRuntimeExports.c(28);
404
+ let children;
405
+ let className;
406
+ let errors;
407
+ let files;
408
+ let onAdd;
409
+ let onRemove;
410
+ let ref;
411
+ let rest;
412
+ let t1;
413
+ let t2;
414
+ if ($[0] !== t0) {
415
+ ({
416
+ ref,
417
+ className,
418
+ children,
419
+ disabled: t1,
420
+ isWaiting: t2,
421
+ files,
422
+ errors,
423
+ onAdd,
424
+ onRemove,
425
+ ...rest
426
+ } = t0);
427
+ $[0] = t0;
428
+ $[1] = children;
429
+ $[2] = className;
430
+ $[3] = errors;
431
+ $[4] = files;
432
+ $[5] = onAdd;
433
+ $[6] = onRemove;
434
+ $[7] = ref;
435
+ $[8] = rest;
436
+ $[9] = t1;
437
+ $[10] = t2;
438
+ } else {
439
+ children = $[1];
440
+ className = $[2];
441
+ errors = $[3];
442
+ files = $[4];
443
+ onAdd = $[5];
444
+ onRemove = $[6];
445
+ ref = $[7];
446
+ rest = $[8];
447
+ t1 = $[9];
448
+ t2 = $[10];
449
+ }
450
+ const disabled = t1 === void 0 ? false : t1;
451
+ const isWaiting = t2 === void 0 ? false : t2;
452
+ let t3;
453
+ if ($[11] !== className) {
454
+ t3 = clsx("at-filepicker", className);
455
+ $[11] = className;
456
+ $[12] = t3;
457
+ } else {
458
+ t3 = $[12];
459
+ }
460
+ let t4;
461
+ if ($[13] !== disabled || $[14] !== errors || $[15] !== files || $[16] !== isWaiting || $[17] !== onAdd || $[18] !== onRemove) {
462
+ t4 = {
463
+ files,
464
+ errors,
465
+ disabled,
466
+ isWaiting,
467
+ onAdd,
468
+ onRemove
469
+ };
470
+ $[13] = disabled;
471
+ $[14] = errors;
472
+ $[15] = files;
473
+ $[16] = isWaiting;
474
+ $[17] = onAdd;
475
+ $[18] = onRemove;
476
+ $[19] = t4;
477
+ } else {
478
+ t4 = $[19];
479
+ }
480
+ let t5;
481
+ if ($[20] !== children || $[21] !== t4) {
482
+ t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(FilePickerContext, { value: t4, children });
483
+ $[20] = children;
484
+ $[21] = t4;
485
+ $[22] = t5;
486
+ } else {
487
+ t5 = $[22];
488
+ }
489
+ let t6;
490
+ if ($[23] !== ref || $[24] !== rest || $[25] !== t3 || $[26] !== t5) {
491
+ t6 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref, className: t3, ...rest, children: t5 });
492
+ $[23] = ref;
493
+ $[24] = rest;
494
+ $[25] = t3;
495
+ $[26] = t5;
496
+ $[27] = t6;
497
+ } else {
498
+ t6 = $[27];
499
+ }
500
+ return t6;
501
+ }
502
+ function DefaultLabel(t0) {
503
+ const $ = compilerRuntimeExports.c(10);
504
+ const {
505
+ defaultLabelText
506
+ } = t0;
507
+ const text1 = defaultLabelText == null ? void 0 : defaultLabelText[0];
508
+ const text2 = defaultLabelText == null ? void 0 : defaultLabelText[1];
509
+ let t1;
510
+ let t2;
511
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
512
+ t1 = {
513
+ display: "flex",
514
+ flexFlow: "row"
515
+ };
516
+ t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.CloudUpIcon, {});
517
+ $[0] = t1;
518
+ $[1] = t2;
519
+ } else {
520
+ t1 = $[0];
521
+ t2 = $[1];
522
+ }
523
+ let t3;
524
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
525
+ t3 = {
526
+ textDecoration: "underline"
527
+ };
528
+ $[2] = t3;
529
+ } else {
530
+ t3 = $[2];
531
+ }
532
+ let t4;
533
+ if ($[3] !== text1) {
534
+ t4 = /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: t1, children: [
535
+ t2,
536
+ /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Label, { style: t3, children: text1 })
537
+ ] });
538
+ $[3] = text1;
539
+ $[4] = t4;
540
+ } else {
541
+ t4 = $[4];
542
+ }
543
+ let t5;
544
+ if ($[5] !== text2) {
545
+ t5 = text2 && /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Label, { children: text2 });
546
+ $[5] = text2;
547
+ $[6] = t5;
548
+ } else {
549
+ t5 = $[6];
550
+ }
551
+ let t6;
552
+ if ($[7] !== t4 || $[8] !== t5) {
553
+ t6 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
554
+ t4,
555
+ t5
556
+ ] });
557
+ $[7] = t4;
558
+ $[8] = t5;
559
+ $[9] = t6;
560
+ } else {
561
+ t6 = $[9];
562
+ }
563
+ return t6;
564
+ }
565
+ function FilePickerDropzone(t0) {
566
+ const $ = compilerRuntimeExports.c(36);
567
+ let className;
568
+ let label;
569
+ let rest;
570
+ let t1;
571
+ let t2;
572
+ if ($[0] !== t0) {
573
+ ({
574
+ className,
575
+ label,
576
+ defaultLabelText: t1,
577
+ dropLabel: t2,
578
+ ...rest
579
+ } = t0);
580
+ $[0] = t0;
581
+ $[1] = className;
582
+ $[2] = label;
583
+ $[3] = rest;
584
+ $[4] = t1;
585
+ $[5] = t2;
586
+ } else {
587
+ className = $[1];
588
+ label = $[2];
589
+ rest = $[3];
590
+ t1 = $[4];
591
+ t2 = $[5];
592
+ }
593
+ let t3;
594
+ if ($[6] !== t1) {
595
+ t3 = t1 === void 0 ? ["Last opp fil", "Filformater: pdf, txt og docx"] : t1;
596
+ $[6] = t1;
597
+ $[7] = t3;
598
+ } else {
599
+ t3 = $[7];
600
+ }
601
+ const defaultLabelText = t3;
602
+ const dropLabel = t2 === void 0 ? "Slipp for å legge til" : t2;
603
+ const {
604
+ onAdd,
605
+ disabled,
606
+ isWaiting
607
+ } = require$$0.use(FilePickerContext);
608
+ let t4;
609
+ if ($[8] !== onAdd) {
610
+ t4 = (acceptedFiles) => {
611
+ onAdd(acceptedFiles);
612
+ };
613
+ $[8] = onAdd;
614
+ $[9] = t4;
615
+ } else {
616
+ t4 = $[9];
617
+ }
618
+ const onDrop = t4;
619
+ let t5;
620
+ if ($[10] !== onDrop) {
621
+ t5 = {
622
+ onDrop
623
+ };
624
+ $[10] = onDrop;
625
+ $[11] = t5;
626
+ } else {
627
+ t5 = $[11];
628
+ }
629
+ const {
630
+ getRootProps,
631
+ getInputProps,
632
+ isDragActive
633
+ } = reactDropzone.useDropzone(t5);
634
+ let t6;
635
+ if ($[12] !== className) {
636
+ t6 = clsx("at-filepicker-dropzone", className);
637
+ $[12] = className;
638
+ $[13] = t6;
639
+ } else {
640
+ t6 = $[13];
641
+ }
642
+ const t7 = disabled || isWaiting;
643
+ let t8;
644
+ if ($[14] !== getRootProps || $[15] !== rest) {
645
+ t8 = getRootProps({
646
+ role: "button",
647
+ ...rest
648
+ });
649
+ $[14] = getRootProps;
650
+ $[15] = rest;
651
+ $[16] = t8;
652
+ } else {
653
+ t8 = $[16];
654
+ }
655
+ let t9;
656
+ if ($[17] !== getInputProps) {
657
+ t9 = getInputProps();
658
+ $[17] = getInputProps;
659
+ $[18] = t9;
660
+ } else {
661
+ t9 = $[18];
662
+ }
663
+ let t10;
664
+ if ($[19] !== t9) {
665
+ t10 = /* @__PURE__ */ jsxRuntimeExports.jsx("input", { ...t9 });
666
+ $[19] = t9;
667
+ $[20] = t10;
668
+ } else {
669
+ t10 = $[20];
670
+ }
671
+ let t11;
672
+ if ($[21] !== isWaiting) {
673
+ t11 = isWaiting && /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Spinner, { "aria-label": "Processing files", "data-size": "lg" });
674
+ $[21] = isWaiting;
675
+ $[22] = t11;
676
+ } else {
677
+ t11 = $[22];
678
+ }
679
+ let t12;
680
+ if ($[23] !== defaultLabelText || $[24] !== dropLabel || $[25] !== isDragActive || $[26] !== isWaiting || $[27] !== label) {
681
+ t12 = !isWaiting && (isDragActive ? /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Label, { children: dropLabel }) : label ?? /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultLabel, { defaultLabelText }));
682
+ $[23] = defaultLabelText;
683
+ $[24] = dropLabel;
684
+ $[25] = isDragActive;
685
+ $[26] = isWaiting;
686
+ $[27] = label;
687
+ $[28] = t12;
688
+ } else {
689
+ t12 = $[28];
690
+ }
691
+ let t13;
692
+ if ($[29] !== t10 || $[30] !== t11 || $[31] !== t12 || $[32] !== t6 || $[33] !== t7 || $[34] !== t8) {
693
+ t13 = /* @__PURE__ */ jsxRuntimeExports.jsxs(designsystemetReact.Button, { className: t6, disabled: t7, ...t8, children: [
694
+ t10,
695
+ t11,
696
+ t12
697
+ ] });
698
+ $[29] = t10;
699
+ $[30] = t11;
700
+ $[31] = t12;
701
+ $[32] = t6;
702
+ $[33] = t7;
703
+ $[34] = t8;
704
+ $[35] = t13;
705
+ } else {
706
+ t13 = $[35];
707
+ }
708
+ return t13;
709
+ }
710
+ function FilePickerErrors(t0) {
711
+ const $ = compilerRuntimeExports.c(11);
712
+ let className;
713
+ let rest;
714
+ if ($[0] !== t0) {
715
+ ({
716
+ className,
717
+ ...rest
718
+ } = t0);
719
+ $[0] = t0;
720
+ $[1] = className;
721
+ $[2] = rest;
722
+ } else {
723
+ className = $[1];
724
+ rest = $[2];
725
+ }
726
+ const {
727
+ errors
728
+ } = require$$0.use(FilePickerContext);
729
+ if (!(errors == null ? void 0 : errors.length)) {
730
+ return null;
731
+ }
732
+ let t1;
733
+ if ($[3] !== className) {
734
+ t1 = clsx("at-filepicker-errors", className);
735
+ $[3] = className;
736
+ $[4] = t1;
737
+ } else {
738
+ t1 = $[4];
739
+ }
740
+ let t2;
741
+ if ($[5] !== errors) {
742
+ t2 = errors.map(_temp);
743
+ $[5] = errors;
744
+ $[6] = t2;
745
+ } else {
746
+ t2 = $[6];
747
+ }
748
+ let t3;
749
+ if ($[7] !== rest || $[8] !== t1 || $[9] !== t2) {
750
+ t3 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: t1, ...rest, children: t2 });
751
+ $[7] = rest;
752
+ $[8] = t1;
753
+ $[9] = t2;
754
+ $[10] = t3;
755
+ } else {
756
+ t3 = $[10];
757
+ }
758
+ return t3;
759
+ }
760
+ function _temp(error, index) {
761
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Alert, { role: "alert", "data-color": "danger", "data-size": "sm", children: error }, index);
762
+ }
763
+ function formatFileSize(bytes) {
764
+ if (bytes === 0) return "0 Bytes";
765
+ const k = 1024;
766
+ const sizes = ["Bytes", "KB", "MB", "GB"];
767
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
768
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
769
+ }
770
+ function FilePickerFiles(t0) {
771
+ const $ = compilerRuntimeExports.c(16);
772
+ let className;
773
+ let rest;
774
+ if ($[0] !== t0) {
775
+ ({
776
+ className,
777
+ ...rest
778
+ } = t0);
779
+ $[0] = t0;
780
+ $[1] = className;
781
+ $[2] = rest;
782
+ } else {
783
+ className = $[1];
784
+ rest = $[2];
785
+ }
786
+ const {
787
+ files,
788
+ onRemove,
789
+ disabled
790
+ } = require$$0.use(FilePickerContext);
791
+ if (!(files == null ? void 0 : files.length)) {
792
+ return null;
793
+ }
794
+ let t1;
795
+ if ($[3] !== className) {
796
+ t1 = clsx("at-filepicker-files", className);
797
+ $[3] = className;
798
+ $[4] = t1;
799
+ } else {
800
+ t1 = $[4];
801
+ }
802
+ let t2;
803
+ if ($[5] !== disabled || $[6] !== files || $[7] !== onRemove) {
804
+ let t32;
805
+ if ($[9] !== disabled || $[10] !== onRemove) {
806
+ t32 = (t4) => {
807
+ const {
808
+ id,
809
+ file,
810
+ error
811
+ } = t4;
812
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(require$$0.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "at-filepicker-file", children: [
813
+ /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.FileIcon, { "aria-hidden": "true", fontSize: "1.5em" }),
814
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "at-filepicker-file__content", children: [
815
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "at-filepicker-file__name", title: file.name, children: file.name }),
816
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.ValidationMessage, { className: "at-filepicker-file__error", "data-color": "danger", "data-size": "sm", title: error, children: error })
817
+ ] }),
818
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "at-filepicker-file__size", "data-size": "sm", children: [
819
+ "(",
820
+ formatFileSize(file.size),
821
+ ")"
822
+ ] }),
823
+ /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Button, { icon: true, variant: "tertiary", "data-size": "sm", onClick: () => onRemove(id), disabled, "aria-label": `Remove ${file.name}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.XMarkIcon, { "aria-hidden": true }) })
824
+ ] }) }, id);
825
+ };
826
+ $[9] = disabled;
827
+ $[10] = onRemove;
828
+ $[11] = t32;
829
+ } else {
830
+ t32 = $[11];
831
+ }
832
+ t2 = files.map(t32);
833
+ $[5] = disabled;
834
+ $[6] = files;
835
+ $[7] = onRemove;
836
+ $[8] = t2;
837
+ } else {
838
+ t2 = $[8];
839
+ }
840
+ let t3;
841
+ if ($[12] !== rest || $[13] !== t1 || $[14] !== t2) {
842
+ t3 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: t1, ...rest, children: t2 });
843
+ $[12] = rest;
844
+ $[13] = t1;
845
+ $[14] = t2;
846
+ $[15] = t3;
847
+ } else {
848
+ t3 = $[15];
849
+ }
850
+ return t3;
851
+ }
852
+ const FilePicker = Object.assign(FilePicker$1, {
853
+ Dropzone: FilePickerDropzone,
854
+ Files: FilePickerFiles,
855
+ Errors: FilePickerErrors
856
+ });
386
857
  function TempExample(t0) {
387
858
  const $ = compilerRuntimeExports.c(9);
388
859
  const {
@@ -573,34 +1044,6 @@ Object.defineProperty(exports, "DropdownTriggerContext", {
573
1044
  enumerable: true,
574
1045
  get: () => designsystemetReact.DropdownTriggerContext
575
1046
  });
576
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestion", {
577
- enumerable: true,
578
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestion
579
- });
580
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestionChips", {
581
- enumerable: true,
582
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestionChips
583
- });
584
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestionClear", {
585
- enumerable: true,
586
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestionClear
587
- });
588
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestionEmpty", {
589
- enumerable: true,
590
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestionEmpty
591
- });
592
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestionInput", {
593
- enumerable: true,
594
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestionInput
595
- });
596
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestionList", {
597
- enumerable: true,
598
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestionList
599
- });
600
- Object.defineProperty(exports, "EXPERIMENTAL_MultiSuggestionOption", {
601
- enumerable: true,
602
- get: () => designsystemetReact.EXPERIMENTAL_MultiSuggestionOption
603
- });
604
1047
  Object.defineProperty(exports, "EXPERIMENTAL_Suggestion", {
605
1048
  enumerable: true,
606
1049
  get: () => designsystemetReact.EXPERIMENTAL_Suggestion
@@ -913,5 +1356,10 @@ Object.defineProperty(exports, "useSynchronizedAnimation", {
913
1356
  enumerable: true,
914
1357
  get: () => designsystemetReact.useSynchronizedAnimation
915
1358
  });
1359
+ exports.FilePicker = FilePicker;
1360
+ exports.FilePickerContext = FilePickerContext;
1361
+ exports.FilePickerDropzone = FilePickerDropzone;
1362
+ exports.FilePickerErrors = FilePickerErrors;
1363
+ exports.FilePickerFiles = FilePickerFiles;
916
1364
  exports.TempExample = TempExample;
917
1365
  //# sourceMappingURL=index.cjs.map