@fremtind/jokul 0.27.6 → 0.28.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/build/build-stats.html +1 -1
- package/build/cjs/components/file-input/File.cjs +2 -0
- package/build/cjs/components/file-input/File.cjs.map +1 -0
- package/build/cjs/components/file-input/File.d.cts +15 -0
- package/build/cjs/components/file-input/FileInput.cjs +2 -0
- package/build/cjs/components/file-input/FileInput.cjs.map +1 -0
- package/build/cjs/components/file-input/FileInput.d.cts +26 -0
- package/build/cjs/components/file-input/index.cjs +2 -0
- package/build/cjs/components/file-input/index.cjs.map +1 -0
- package/build/cjs/components/file-input/index.d.cts +4 -0
- package/build/cjs/components/file-input/internal/Dropzone.cjs +2 -0
- package/build/cjs/components/file-input/internal/Dropzone.cjs.map +1 -0
- package/build/cjs/components/file-input/internal/Dropzone.d.cts +6 -0
- package/build/cjs/components/file-input/internal/Input.cjs +2 -0
- package/build/cjs/components/file-input/internal/Input.cjs.map +1 -0
- package/build/cjs/components/file-input/internal/Input.d.cts +8 -0
- package/build/cjs/components/file-input/internal/Thumbnail.cjs +2 -0
- package/build/cjs/components/file-input/internal/Thumbnail.cjs.map +1 -0
- package/build/cjs/components/file-input/internal/Thumbnail.d.cts +11 -0
- package/build/cjs/components/file-input/internal/fileInputContext.cjs +2 -0
- package/build/cjs/components/file-input/internal/fileInputContext.cjs.map +1 -0
- package/build/cjs/components/file-input/internal/fileInputContext.d.cts +15 -0
- package/build/cjs/components/file-input/internal/validateFile.cjs +2 -0
- package/build/cjs/components/file-input/internal/validateFile.cjs.map +1 -0
- package/build/cjs/components/file-input/internal/validateFile.d.cts +2 -0
- package/build/cjs/components/file-input/types.cjs +2 -0
- package/build/cjs/components/file-input/types.cjs.map +1 -0
- package/build/cjs/components/file-input/types.d.cts +11 -0
- package/build/cjs/components/file-input/utils.cjs +2 -0
- package/build/cjs/components/file-input/utils.cjs.map +1 -0
- package/build/cjs/components/file-input/utils.d.cts +11 -0
- package/build/cjs/components/select/Select.cjs +1 -1
- package/build/cjs/components/select/Select.cjs.map +1 -1
- package/build/cjs/core/tokens.cjs +1 -1
- package/build/cjs/core/tokens.cjs.map +1 -1
- package/build/cjs/core/tokens.d.cts +5 -1
- package/build/es/components/file-input/File.d.ts +15 -0
- package/build/es/components/file-input/File.js +2 -0
- package/build/es/components/file-input/File.js.map +1 -0
- package/build/es/components/file-input/FileInput.d.ts +26 -0
- package/build/es/components/file-input/FileInput.js +2 -0
- package/build/es/components/file-input/FileInput.js.map +1 -0
- package/build/es/components/file-input/index.d.ts +4 -0
- package/build/es/components/file-input/index.js +2 -0
- package/build/es/components/file-input/index.js.map +1 -0
- package/build/es/components/file-input/internal/Dropzone.d.ts +6 -0
- package/build/es/components/file-input/internal/Dropzone.js +2 -0
- package/build/es/components/file-input/internal/Dropzone.js.map +1 -0
- package/build/es/components/file-input/internal/Input.d.ts +8 -0
- package/build/es/components/file-input/internal/Input.js +2 -0
- package/build/es/components/file-input/internal/Input.js.map +1 -0
- package/build/es/components/file-input/internal/Thumbnail.d.ts +11 -0
- package/build/es/components/file-input/internal/Thumbnail.js +2 -0
- package/build/es/components/file-input/internal/Thumbnail.js.map +1 -0
- package/build/es/components/file-input/internal/fileInputContext.d.ts +15 -0
- package/build/es/components/file-input/internal/fileInputContext.js +2 -0
- package/build/es/components/file-input/internal/fileInputContext.js.map +1 -0
- package/build/es/components/file-input/internal/validateFile.d.ts +2 -0
- package/build/es/components/file-input/internal/validateFile.js +2 -0
- package/build/es/components/file-input/internal/validateFile.js.map +1 -0
- package/build/es/components/file-input/types.d.ts +11 -0
- package/build/es/components/file-input/types.js +2 -0
- package/build/es/components/file-input/types.js.map +1 -0
- package/build/es/components/file-input/utils.d.ts +11 -0
- package/build/es/components/file-input/utils.js +2 -0
- package/build/es/components/file-input/utils.js.map +1 -0
- package/build/es/components/select/Select.js +1 -1
- package/build/es/components/select/Select.js.map +1 -1
- package/build/es/core/tokens.d.ts +5 -1
- package/build/es/core/tokens.js +1 -1
- package/build/es/core/tokens.js.map +1 -1
- package/package.json +12 -2
- package/styles/components/accordion/accordion.css +1 -1
- package/styles/components/breadcrumb/breadcrumb.css +1 -1
- package/styles/components/button/button.css +3 -3
- package/styles/components/button/button.min.css +1 -1
- package/styles/components/card/card.css +1 -1
- package/styles/components/checkbox/checkbox.css +5 -5
- package/styles/components/checkbox/checkbox.min.css +1 -1
- package/styles/components/combobox/combobox.css +1 -1
- package/styles/components/cookie-consent/cookie-consent.css +1 -1
- package/styles/components/datepicker/datepicker.css +1 -1
- package/styles/components/description-list/description-list.css +1 -1
- package/styles/components/expander/expander.css +1 -1
- package/styles/components/feedback/feedback.css +3 -3
- package/styles/components/feedback/feedback.min.css +1 -1
- package/styles/components/file-input/_file.scss +172 -0
- package/styles/components/file-input/_index.scss +1 -0
- package/styles/components/file-input/file-input.css +290 -0
- package/styles/components/file-input/file-input.min.css +1 -0
- package/styles/components/file-input/file-input.scss +119 -0
- package/styles/components/icon/icon.css +1 -1
- package/styles/components/icon-button/icon-button.css +1 -1
- package/styles/components/image/image.css +1 -1
- package/styles/components/input-group/input-group.css +3 -3
- package/styles/components/input-group/input-group.min.css +1 -1
- package/styles/components/link/link.css +1 -1
- package/styles/components/link-list/link-list.css +1 -1
- package/styles/components/list/list.css +1 -1
- package/styles/components/loader/loader.css +7 -7
- package/styles/components/loader/loader.min.css +1 -1
- package/styles/components/loader/skeleton-loader.css +6 -6
- package/styles/components/loader/skeleton-loader.min.css +1 -1
- package/styles/components/logo/logo.css +1 -1
- package/styles/components/menu/menu.css +1 -1
- package/styles/components/message/message.css +3 -3
- package/styles/components/message/message.min.css +1 -1
- package/styles/components/modal/modal.css +1 -1
- package/styles/components/pagination/pagination.css +1 -1
- package/styles/components/popover/popover.css +1 -1
- package/styles/components/progress-bar/progress-bar.css +3 -3
- package/styles/components/progress-bar/progress-bar.min.css +1 -1
- package/styles/components/radio-button/radio-button.css +3 -3
- package/styles/components/radio-button/radio-button.min.css +1 -1
- package/styles/components/radio-panel/radio-panel.css +3 -3
- package/styles/components/radio-panel/radio-panel.min.css +1 -1
- package/styles/components/select/select.css +55 -145
- package/styles/components/select/select.min.css +1 -1
- package/styles/components/select/select.scss +62 -119
- package/styles/components/summary-table/summary-table.css +1 -1
- package/styles/components/system-message/system-message.css +3 -3
- package/styles/components/system-message/system-message.min.css +1 -1
- package/styles/components/table/table.css +1 -1
- package/styles/components/tabs/tabs.css +1 -1
- package/styles/components/tag/tag.css +1 -1
- package/styles/components/text-input/text-input.css +3 -3
- package/styles/components/text-input/text-input.min.css +1 -1
- package/styles/components/text-input/text-input.scss +1 -1
- package/styles/components/toast/toast.css +5 -5
- package/styles/components/toast/toast.min.css +1 -1
- package/styles/components/toggle-switch/toggle-switch.css +1 -1
- package/styles/components/tooltip/tooltip.css +1 -1
- package/styles/core/_color-tokens.scss +3 -1
- package/styles/core/_legacy-tokens.scss +1 -1
- package/styles/core/_tokens.scss +1 -1
- package/styles/core/core.css +8 -4
- package/styles/core/core.min.css +1 -1
- package/styles/core/jkl/_legacy-tokens.scss +1 -1
- package/styles/core/jkl/_tokens.scss +2 -1
- package/styles/styles.css +91 -181
- package/styles/styles.min.css +1 -1
- package/styles/vind/vind.css +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.cjs","sources":["../../../src/core/tokens.ts"],"sourcesContent":["/**\n * Do not edit directly\n * Generated on Mon, 23 Sep 2024 08:51:40 GMT\n */\n\nexport default {\n breakpoint: {\n medium: \"680px\",\n large: \"1200px\",\n xl: \"1600px\",\n },\n color: {\n brand: {\n snohvit: \"#F9F9F9\",\n varde: \"#E0DBD4\",\n granitt: \"#1B1917\",\n hvit: \"#FFFFFF\",\n svart: \"#000000\",\n skifer: \"#313030\",\n fjellgra: \"#444141\",\n stein: \"#636060\",\n svaberg: \"#C8C5C3\",\n dis: \"#ECE9E5\",\n sand: \"#F4F2EF\",\n },\n functional: {\n info: \"#D3D3F6\",\n infoDark: \"#A9A9CA\",\n success: \"#ACD3B5\",\n successDark: \"#94B79B\",\n warning: \"#EFDD9E\",\n warningDark: \"#DECC8D\",\n error: \"#F6B3B3\",\n errorDark: \"#DE9E9E\",\n },\n background: {\n page: {\n light: \"#F4F2EF\",\n dark: \"#1B1917\",\n },\n pageVariant: {\n light: \"#F9F9F9\",\n dark: \"#1B1917\",\n },\n container: {\n light: \"#F9F9F9\",\n dark: \"#313030\",\n },\n containerLow: {\n light: \"#ECE9E5\",\n dark: \"#000000\",\n },\n containerHigh: {\n light: \"#FFFFFF\",\n dark: \"#313030\",\n },\n containerInverted: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n containerSubdued: {\n light: \"#C8C5C3\",\n dark: \"#636060\",\n },\n input: {\n base: {\n light: \"transparent\",\n dark: \"transparent\",\n },\n focus: {\n light: \"#FFFFFF\",\n dark: \"#313030\",\n },\n },\n action: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n interactive: {\n light: \"transparent\",\n dark: \"transparent\",\n },\n interactiveHover: {\n light: \"#ECE9E5\",\n dark: \"#444141\",\n },\n interactiveSelected: {\n light: \"#E0DBD4\",\n dark: \"#636060\",\n },\n alert: {\n neutral: {\n light: \"#E0DBD4\",\n dark: \"#E0DBD4\",\n },\n info: {\n light: \"#D3D3F6\",\n dark: \"#A9A9CA\",\n },\n success: {\n light: \"#ACD3B5\",\n dark: \"#94B79B\",\n },\n warning: {\n light: \"#EFDD9E\",\n dark: \"#DECC8D\",\n },\n error: {\n light: \"#F6B3B3\",\n dark: \"#DE9E9E\",\n },\n },\n },\n text: {\n default: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n subdued: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n inverted: {\n light: \"#F9F9F9\",\n dark: \"#1B1917\",\n },\n onAction: {\n light: \"#F9F9F9\",\n dark: \"#1B1917\",\n },\n interactive: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n interactiveHover: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n onAlert: {\n light: \"#1B1917\",\n dark: \"#1B1917\",\n },\n },\n border: {\n action: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n input: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n inputFocus: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n separator: {\n light: \"#C8C5C3\",\n dark: \"#636060\",\n },\n separatorStrong: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n separatorHover: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n subdued: {\n light: \"#C8C5C3\",\n dark: \"#636060\",\n },\n },\n svart: \"#000\",\n granitt: \"#1b1917\",\n skifer: \"#313030\",\n fjellgra: \"#444141\",\n stein: \"#636060\",\n svaberg: \"#c8c5c3\",\n varde: \"#e0dbd4\",\n dis: \"#ece9e5\",\n sand: \"#f4f2ef\",\n snohvit: \"#f9f9f9\",\n hvit: \"#fff\",\n suksess: \"#acd3b5\",\n suksessDark: \"#94b79b\",\n feil: \"#f6b3b3\",\n feilDark: \"#de9e9e\",\n info: \"#d3d3f6\",\n infoDark: \"#a9a9ca\",\n advarsel: \"#efdd9e\",\n advarselDark: \"#decc8d\",\n },\n motion: {\n timing: {\n energetic: \"75ms\",\n snappy: \"100ms\",\n productive: \"150ms\",\n expressive: \"250ms\",\n lazy: \"400ms\",\n },\n easing: {\n standard: \"ease\",\n entrance: \"ease-out\",\n exit: \"ease-in\",\n easeInBounceOut: \"cubic-bezier(0, 0, 0.375, 1.17)\",\n focus: \"cubic-bezier(0.6, 0.2, 0.35, 1)\",\n },\n },\n spacing: {\n 0: \"0\",\n 2: \"0.125rem\",\n 4: \"0.25rem\",\n 8: \"0.5rem\",\n 12: \"0.75rem\",\n 16: \"1rem\",\n 24: \"1.5rem\",\n 32: \"2rem\",\n 40: \"2.5rem\",\n 64: \"4rem\",\n 104: \"6.5rem\",\n 168: \"10.5rem\",\n },\n icon: {\n weight: {\n normal: \"300\",\n bold: \"500\",\n },\n },\n typography: {\n weight: {\n normal: \"400\",\n bold: \"700\",\n },\n font: {\n size: {\n 16: \"1rem\",\n 18: \"1.125rem\",\n 20: \"1.25rem\",\n 21: \"1.3125rem\",\n 23: \"1.4375rem\",\n 25: \"1.5625rem\",\n 26: \"1.625rem\",\n 28: \"1.75rem\",\n 30: \"1.875rem\",\n 36: \"2.25rem\",\n 44: \"2.75rem\",\n 56: \"3.5rem\",\n },\n },\n line: {\n height: {\n 24: \"1.5rem\",\n 28: \"1.75rem\",\n 32: \"2rem\",\n 36: \"2.25rem\",\n 40: \"2.5rem\",\n 44: \"2.75rem\",\n 52: \"3.25rem\",\n 64: \"4rem\",\n },\n },\n title: {\n small: {\n fontSize: \"2.25rem\",\n lineHeight: \"2.75rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"3.5rem\",\n lineHeight: \"4rem\",\n fontWeight: \"400\",\n },\n },\n titleSmall: {\n small: {\n fontSize: \"1.875rem\",\n lineHeight: \"2.25rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"2.75rem\",\n lineHeight: \"3.25rem\",\n fontWeight: \"400\",\n },\n },\n heading_1: {\n small: {\n fontSize: \"1.625rem\",\n lineHeight: \"2rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"2.25rem\",\n lineHeight: \"2.75rem\",\n fontWeight: \"400\",\n },\n },\n heading_2: {\n small: {\n fontSize: \"1.4375rem\",\n lineHeight: \"2rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"1.75rem\",\n lineHeight: \"2.5rem\",\n fontWeight: \"400\",\n },\n },\n heading_3: {\n small: {\n fontSize: \"1.3125rem\",\n lineHeight: \"1.75rem\",\n fontWeight: \"700\",\n },\n base: {\n fontSize: \"1.5625rem\",\n lineHeight: \"2rem\",\n fontWeight: \"700\",\n },\n },\n heading_4: {\n small: {\n fontSize: \"1.125rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"700\",\n },\n base: {\n fontSize: \"1.3125rem\",\n lineHeight: \"1.75rem\",\n fontWeight: \"700\",\n },\n },\n heading_5: {\n small: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"700\",\n },\n base: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"700\",\n },\n },\n body: {\n small: {\n fontSize: \"1.125rem\",\n lineHeight: \"1.75rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"1.25rem\",\n lineHeight: \"2rem\",\n fontWeight: \"400\",\n },\n },\n small: {\n small: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"400\",\n },\n },\n },\n};\n"],"names":["breakpoint","medium","large","xl","color","brand","snohvit","varde","granitt","hvit","svart","skifer","fjellgra","stein","svaberg","dis","sand","functional","info","infoDark","success","successDark","warning","warningDark","error","errorDark","background","page","light","dark","pageVariant","container","containerLow","containerHigh","containerInverted","containerSubdued","input","base","focus","action","interactive","interactiveHover","interactiveSelected","alert","neutral","text","default","subdued","inverted","onAction","onAlert","border","inputFocus","separator","separatorStrong","separatorHover","suksess","suksessDark","feil","feilDark","advarsel","advarselDark","motion","timing","energetic","snappy","productive","expressive","lazy","easing","standard","entrance","exit","easeInBounceOut","spacing","icon","weight","normal","bold","typography","font","size","line","height","title","small","fontSize","lineHeight","fontWeight","titleSmall","heading_1","heading_2","heading_3","heading_4","heading_5","body"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"tokens.cjs","sources":["../../../src/core/tokens.ts"],"sourcesContent":["/**\n * Do not edit directly\n * Generated on Mon, 28 Oct 2024 14:22:00 GMT\n */\n\nexport default {\n breakpoint: {\n medium: \"680px\",\n large: \"1200px\",\n xl: \"1600px\",\n },\n color: {\n brand: {\n snohvit: \"#F9F9F9\",\n varde: \"#E0DBD4\",\n granitt: \"#1B1917\",\n hvit: \"#FFFFFF\",\n svart: \"#000000\",\n skifer: \"#313030\",\n fjellgra: \"#444141\",\n stein: \"#636060\",\n svaberg: \"#C8C5C3\",\n dis: \"#ECE9E5\",\n sand: \"#F4F2EF\",\n },\n functional: {\n info: \"#D3D3F6\",\n infoDark: \"#A9A9CA\",\n success: \"#ACD3B5\",\n successDark: \"#94B79B\",\n warning: \"#EFDD9E\",\n warningDark: \"#DECC8D\",\n error: \"#F6B3B3\",\n errorDark: \"#DE9E9E\",\n },\n background: {\n page: {\n light: \"#F4F2EF\",\n dark: \"#1B1917\",\n },\n pageVariant: {\n light: \"#F9F9F9\",\n dark: \"#1B1917\",\n },\n container: {\n light: \"#F9F9F9\",\n dark: \"#313030\",\n },\n containerLow: {\n light: \"#ECE9E5\",\n dark: \"#000000\",\n },\n containerHigh: {\n light: \"#FFFFFF\",\n dark: \"#313030\",\n },\n containerInverted: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n containerSubdued: {\n light: \"#C8C5C3\",\n dark: \"#636060\",\n },\n input: {\n base: {\n light: \"transparent\",\n dark: \"transparent\",\n },\n focus: {\n light: \"#FFFFFF\",\n dark: \"#313030\",\n },\n },\n action: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n interactive: {\n light: \"transparent\",\n dark: \"transparent\",\n },\n interactiveHover: {\n light: \"#ECE9E5\",\n dark: \"#444141\",\n },\n interactiveSelected: {\n light: \"#E0DBD4\",\n dark: \"#636060\",\n },\n alert: {\n neutral: {\n light: \"#E0DBD4\",\n dark: \"#E0DBD4\",\n },\n info: {\n light: \"#D3D3F6\",\n dark: \"#A9A9CA\",\n },\n success: {\n light: \"#ACD3B5\",\n dark: \"#94B79B\",\n },\n warning: {\n light: \"#EFDD9E\",\n dark: \"#DECC8D\",\n },\n error: {\n light: \"#F6B3B3\",\n dark: \"#DE9E9E\",\n },\n },\n },\n text: {\n default: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n subdued: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n inverted: {\n light: \"#F9F9F9\",\n dark: \"#1B1917\",\n },\n onAction: {\n light: \"#F9F9F9\",\n dark: \"#1B1917\",\n },\n interactive: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n interactiveHover: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n onAlert: {\n light: \"#1B1917\",\n dark: \"#1B1917\",\n },\n onAlertSubdued: {\n light: \"#444141\",\n dark: \"#444141\",\n },\n },\n border: {\n action: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n input: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n inputFocus: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n separator: {\n light: \"#C8C5C3\",\n dark: \"#636060\",\n },\n separatorStrong: {\n light: \"#636060\",\n dark: \"#C8C5C3\",\n },\n separatorHover: {\n light: \"#1B1917\",\n dark: \"#F9F9F9\",\n },\n subdued: {\n light: \"#C8C5C3\",\n dark: \"#636060\",\n },\n },\n svart: \"#000\",\n granitt: \"#1b1917\",\n skifer: \"#313030\",\n fjellgra: \"#444141\",\n stein: \"#636060\",\n svaberg: \"#c8c5c3\",\n varde: \"#e0dbd4\",\n dis: \"#ece9e5\",\n sand: \"#f4f2ef\",\n snohvit: \"#f9f9f9\",\n hvit: \"#fff\",\n suksess: \"#acd3b5\",\n suksessDark: \"#94b79b\",\n feil: \"#f6b3b3\",\n feilDark: \"#de9e9e\",\n info: \"#d3d3f6\",\n infoDark: \"#a9a9ca\",\n advarsel: \"#efdd9e\",\n advarselDark: \"#decc8d\",\n },\n motion: {\n timing: {\n energetic: \"75ms\",\n snappy: \"100ms\",\n productive: \"150ms\",\n expressive: \"250ms\",\n lazy: \"400ms\",\n },\n easing: {\n standard: \"ease\",\n entrance: \"ease-out\",\n exit: \"ease-in\",\n easeInBounceOut: \"cubic-bezier(0, 0, 0.375, 1.17)\",\n focus: \"cubic-bezier(0.6, 0.2, 0.35, 1)\",\n },\n },\n spacing: {\n 0: \"0\",\n 2: \"0.125rem\",\n 4: \"0.25rem\",\n 8: \"0.5rem\",\n 12: \"0.75rem\",\n 16: \"1rem\",\n 24: \"1.5rem\",\n 32: \"2rem\",\n 40: \"2.5rem\",\n 64: \"4rem\",\n 104: \"6.5rem\",\n 168: \"10.5rem\",\n },\n icon: {\n weight: {\n normal: \"300\",\n bold: \"500\",\n },\n },\n typography: {\n weight: {\n normal: \"400\",\n bold: \"700\",\n },\n font: {\n size: {\n 16: \"1rem\",\n 18: \"1.125rem\",\n 20: \"1.25rem\",\n 21: \"1.3125rem\",\n 23: \"1.4375rem\",\n 25: \"1.5625rem\",\n 26: \"1.625rem\",\n 28: \"1.75rem\",\n 30: \"1.875rem\",\n 36: \"2.25rem\",\n 44: \"2.75rem\",\n 56: \"3.5rem\",\n },\n },\n line: {\n height: {\n 24: \"1.5rem\",\n 28: \"1.75rem\",\n 32: \"2rem\",\n 36: \"2.25rem\",\n 40: \"2.5rem\",\n 44: \"2.75rem\",\n 52: \"3.25rem\",\n 64: \"4rem\",\n },\n },\n title: {\n small: {\n fontSize: \"2.25rem\",\n lineHeight: \"2.75rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"3.5rem\",\n lineHeight: \"4rem\",\n fontWeight: \"400\",\n },\n },\n titleSmall: {\n small: {\n fontSize: \"1.875rem\",\n lineHeight: \"2.25rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"2.75rem\",\n lineHeight: \"3.25rem\",\n fontWeight: \"400\",\n },\n },\n heading_1: {\n small: {\n fontSize: \"1.625rem\",\n lineHeight: \"2rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"2.25rem\",\n lineHeight: \"2.75rem\",\n fontWeight: \"400\",\n },\n },\n heading_2: {\n small: {\n fontSize: \"1.4375rem\",\n lineHeight: \"2rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"1.75rem\",\n lineHeight: \"2.5rem\",\n fontWeight: \"400\",\n },\n },\n heading_3: {\n small: {\n fontSize: \"1.3125rem\",\n lineHeight: \"1.75rem\",\n fontWeight: \"700\",\n },\n base: {\n fontSize: \"1.5625rem\",\n lineHeight: \"2rem\",\n fontWeight: \"700\",\n },\n },\n heading_4: {\n small: {\n fontSize: \"1.125rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"700\",\n },\n base: {\n fontSize: \"1.3125rem\",\n lineHeight: \"1.75rem\",\n fontWeight: \"700\",\n },\n },\n heading_5: {\n small: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"700\",\n },\n base: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"700\",\n },\n },\n body: {\n small: {\n fontSize: \"1.125rem\",\n lineHeight: \"1.75rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"1.25rem\",\n lineHeight: \"2rem\",\n fontWeight: \"400\",\n },\n },\n small: {\n small: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"400\",\n },\n base: {\n fontSize: \"1rem\",\n lineHeight: \"1.5rem\",\n fontWeight: \"400\",\n },\n },\n },\n};\n"],"names":["breakpoint","medium","large","xl","color","brand","snohvit","varde","granitt","hvit","svart","skifer","fjellgra","stein","svaberg","dis","sand","functional","info","infoDark","success","successDark","warning","warningDark","error","errorDark","background","page","light","dark","pageVariant","container","containerLow","containerHigh","containerInverted","containerSubdued","input","base","focus","action","interactive","interactiveHover","interactiveSelected","alert","neutral","text","default","subdued","inverted","onAction","onAlert","onAlertSubdued","border","inputFocus","separator","separatorStrong","separatorHover","suksess","suksessDark","feil","feilDark","advarsel","advarselDark","motion","timing","energetic","snappy","productive","expressive","lazy","easing","standard","entrance","exit","easeInBounceOut","spacing","icon","weight","normal","bold","typography","font","size","line","height","title","small","fontSize","lineHeight","fontWeight","titleSmall","heading_1","heading_2","heading_3","heading_4","heading_5","body"],"mappings":"AAKA,4BAAe,CACXA,WAAY,CACRC,OAAQ,QACRC,MAAO,SACPC,GAAI,UAERC,MAAO,CACHC,MAAO,CACHC,QAAS,UACTC,MAAO,UACPC,QAAS,UACTC,KAAM,UACNC,MAAO,UACPC,OAAQ,UACRC,SAAU,UACVC,MAAO,UACPC,QAAS,UACTC,IAAK,UACLC,KAAM,WAEVC,WAAY,CACRC,KAAM,UACNC,SAAU,UACVC,QAAS,UACTC,YAAa,UACbC,QAAS,UACTC,YAAa,UACbC,MAAO,UACPC,UAAW,WAEfC,WAAY,CACRC,KAAM,CACFC,MAAO,UACPC,KAAM,WAEVC,YAAa,CACTF,MAAO,UACPC,KAAM,WAEVE,UAAW,CACPH,MAAO,UACPC,KAAM,WAEVG,aAAc,CACVJ,MAAO,UACPC,KAAM,WAEVI,cAAe,CACXL,MAAO,UACPC,KAAM,WAEVK,kBAAmB,CACfN,MAAO,UACPC,KAAM,WAEVM,iBAAkB,CACdP,MAAO,UACPC,KAAM,WAEVO,MAAO,CACHC,KAAM,CACFT,MAAO,cACPC,KAAM,eAEVS,MAAO,CACHV,MAAO,UACPC,KAAM,YAGdU,OAAQ,CACJX,MAAO,UACPC,KAAM,WAEVW,YAAa,CACTZ,MAAO,cACPC,KAAM,eAEVY,iBAAkB,CACdb,MAAO,UACPC,KAAM,WAEVa,oBAAqB,CACjBd,MAAO,UACPC,KAAM,WAEVc,MAAO,CACHC,QAAS,CACLhB,MAAO,UACPC,KAAM,WAEVX,KAAM,CACFU,MAAO,UACPC,KAAM,WAEVT,QAAS,CACLQ,MAAO,UACPC,KAAM,WAEVP,QAAS,CACLM,MAAO,UACPC,KAAM,WAEVL,MAAO,CACHI,MAAO,UACPC,KAAM,aAIlBgB,KAAM,CACFC,QAAS,CACLlB,MAAO,UACPC,KAAM,WAEVkB,QAAS,CACLnB,MAAO,UACPC,KAAM,WAEVmB,SAAU,CACNpB,MAAO,UACPC,KAAM,WAEVoB,SAAU,CACNrB,MAAO,UACPC,KAAM,WAEVW,YAAa,CACTZ,MAAO,UACPC,KAAM,WAEVY,iBAAkB,CACdb,MAAO,UACPC,KAAM,WAEVqB,QAAS,CACLtB,MAAO,UACPC,KAAM,WAEVsB,eAAgB,CACZvB,MAAO,UACPC,KAAM,YAGduB,OAAQ,CACJb,OAAQ,CACJX,MAAO,UACPC,KAAM,WAEVO,MAAO,CACHR,MAAO,UACPC,KAAM,WAEVwB,WAAY,CACRzB,MAAO,UACPC,KAAM,WAEVyB,UAAW,CACP1B,MAAO,UACPC,KAAM,WAEV0B,gBAAiB,CACb3B,MAAO,UACPC,KAAM,WAEV2B,eAAgB,CACZ5B,MAAO,UACPC,KAAM,WAEVkB,QAAS,CACLnB,MAAO,UACPC,KAAM,YAGdnB,MAAO,OACPF,QAAS,UACTG,OAAQ,UACRC,SAAU,UACVC,MAAO,UACPC,QAAS,UACTP,MAAO,UACPQ,IAAK,UACLC,KAAM,UACNV,QAAS,UACTG,KAAM,OACNgD,QAAS,UACTC,YAAa,UACbC,KAAM,UACNC,SAAU,UACV1C,KAAM,UACNC,SAAU,UACV0C,SAAU,UACVC,aAAc,WAElBC,OAAQ,CACJC,OAAQ,CACJC,UAAW,OACXC,OAAQ,QACRC,WAAY,QACZC,WAAY,QACZC,KAAM,SAEVC,OAAQ,CACJC,SAAU,OACVC,SAAU,WACVC,KAAM,UACNC,gBAAiB,kCACjBpC,MAAO,oCAGfqC,QAAS,CACL,EAAG,IACH,EAAG,WACH,EAAG,UACH,EAAG,SACH,GAAI,UACJ,GAAI,OACJ,GAAI,SACJ,GAAI,OACJ,GAAI,SACJ,GAAI,OACJ,IAAK,SACL,IAAK,WAETC,KAAM,CACFC,OAAQ,CACJC,OAAQ,MACRC,KAAM,QAGdC,WAAY,CACRH,OAAQ,CACJC,OAAQ,MACRC,KAAM,OAEVE,KAAM,CACFC,KAAM,CACF,GAAI,OACJ,GAAI,WACJ,GAAI,UACJ,GAAI,YACJ,GAAI,YACJ,GAAI,YACJ,GAAI,WACJ,GAAI,UACJ,GAAI,WACJ,GAAI,UACJ,GAAI,UACJ,GAAI,WAGZC,KAAM,CACFC,OAAQ,CACJ,GAAI,SACJ,GAAI,UACJ,GAAI,OACJ,GAAI,UACJ,GAAI,SACJ,GAAI,UACJ,GAAI,UACJ,GAAI,SAGZC,MAAO,CACHC,MAAO,CACHC,SAAU,UACVC,WAAY,UACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,SACVC,WAAY,OACZC,WAAY,QAGpBC,WAAY,CACRJ,MAAO,CACHC,SAAU,WACVC,WAAY,UACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,UACVC,WAAY,UACZC,WAAY,QAGpBE,UAAW,CACPL,MAAO,CACHC,SAAU,WACVC,WAAY,OACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,UACVC,WAAY,UACZC,WAAY,QAGpBG,UAAW,CACPN,MAAO,CACHC,SAAU,YACVC,WAAY,OACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,UACVC,WAAY,SACZC,WAAY,QAGpBI,UAAW,CACPP,MAAO,CACHC,SAAU,YACVC,WAAY,UACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,YACVC,WAAY,OACZC,WAAY,QAGpBK,UAAW,CACPR,MAAO,CACHC,SAAU,WACVC,WAAY,SACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,YACVC,WAAY,UACZC,WAAY,QAGpBM,UAAW,CACPT,MAAO,CACHC,SAAU,OACVC,WAAY,SACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,OACVC,WAAY,SACZC,WAAY,QAGpBO,KAAM,CACFV,MAAO,CACHC,SAAU,WACVC,WAAY,UACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,UACVC,WAAY,OACZC,WAAY,QAGpBH,MAAO,CACHA,MAAO,CACHC,SAAU,OACVC,WAAY,SACZC,WAAY,OAEhBpD,KAAM,CACFkD,SAAU,OACVC,WAAY,SACZC,WAAY"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Do not edit directly
|
|
3
|
-
* Generated on Mon,
|
|
3
|
+
* Generated on Mon, 28 Oct 2024 14:22:00 GMT
|
|
4
4
|
*/
|
|
5
5
|
declare const _default: {
|
|
6
6
|
breakpoint: {
|
|
@@ -139,6 +139,10 @@ declare const _default: {
|
|
|
139
139
|
light: string;
|
|
140
140
|
dark: string;
|
|
141
141
|
};
|
|
142
|
+
onAlertSubdued: {
|
|
143
|
+
light: string;
|
|
144
|
+
dark: string;
|
|
145
|
+
};
|
|
142
146
|
};
|
|
143
147
|
border: {
|
|
144
148
|
action: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC, MouseEvent } from 'react';
|
|
2
|
+
import { WithOptionalChildren } from '../../core/types.js';
|
|
3
|
+
import { FileInputFileState } from './types.js';
|
|
4
|
+
export interface FileProps extends WithOptionalChildren {
|
|
5
|
+
fileName: string;
|
|
6
|
+
fileType: string;
|
|
7
|
+
fileSize: number;
|
|
8
|
+
path?: string;
|
|
9
|
+
file?: File;
|
|
10
|
+
supportLabel?: string;
|
|
11
|
+
supportLabelType?: "help" | "error" | "warning" | "success";
|
|
12
|
+
state?: FileInputFileState;
|
|
13
|
+
onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const File: FC<FileProps>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as o,jsx as i}from"react/jsx-runtime";import n from"classnames";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import{SuccessIcon as s}from"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import{TrashCanIcon as c}from"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import{IconButton as r}from"../icon-button/IconButton.js";import{SupportLabel as e}from"../input-group/SupportLabel.js";import{useId as t}from"../../hooks/useId/useId.js";import{formatBytes as l}from"../../utilities/formatters/bytes/formatBytes.js";import{useFileInputContext as a}from"./internal/fileInputContext.js";import{Thumbnail as m}from"./internal/Thumbnail.js";const p=p=>{const{children:j,fileName:I,fileType:f,fileSize:u,path:d,file:h,supportLabel:b,supportLabelType:k,state:_,onRemove:C}=p,w=t("jkl-file-preview"),v=w+"-support",T=a(),g="error"===k||"warning"===k,y="success"===k,A=o("div",{id:w,className:"jkl-file",children:[o(d?"a":"div",{className:n("jkl-file__content",{"jkl-file__content--error":"error"===k,"jkl-file__content--warning":"warning"===k}),href:d,target:d?"_blank":void 0,children:[i(m,{fileName:I,fileType:f,file:h,path:d,state:_,children:j}),o("div",{children:[i("p",{className:"jkl-file__name",children:I}),o("p",{className:"jkl-file__description",children:[i("span",{children:l(u)}),g||y?y?i(s,{variant:"small","aria-label":"Filen ble lastet opp uten feil"}):null:i(e,{className:"jkl-file__support-label jkl-body",id:v,label:b,labelType:k})]}),b&&g&&i(e,{className:"jkl-file__support-label",id:v,label:b,labelType:k})]})]}),C&&i(r,{className:"jkl-file__delete",onClick:C,title:`Fjern ${I}`,children:i(c,{})})]});return T?i("li",{children:A}):A};export{p as File};
|
|
2
|
+
//# sourceMappingURL=File.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"File.js","sources":["../../../../src/components/file-input/File.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport React, { FC, MouseEvent } from \"react\";\nimport { TrashCanIcon, SuccessIcon } from \"../../components/icon/index.js\";\nimport { IconButton } from \"../../components/icon-button/IconButton.js\";\nimport { SupportLabel } from \"../../components/input-group/SupportLabel.js\";\nimport { type WithOptionalChildren } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { formatBytes } from \"../../utilities/formatters/bytes/formatBytes.js\";\nimport { useFileInputContext } from \"./internal/fileInputContext.js\";\nimport { Thumbnail } from \"./internal/Thumbnail.js\";\nimport { FileInputFileState } from \"./types.js\";\n\nexport interface FileProps extends WithOptionalChildren {\n fileName: string;\n fileType: string;\n fileSize: number;\n path?: string;\n file?: File;\n supportLabel?: string;\n supportLabelType?: \"help\" | \"error\" | \"warning\" | \"success\";\n state?: FileInputFileState;\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const File: FC<FileProps> = (props) => {\n const {\n children,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n supportLabel,\n supportLabelType,\n state,\n onRemove,\n } = props;\n\n const id = useId(\"jkl-file-preview\");\n const supportId = id + \"-support\";\n\n const context = useFileInputContext();\n\n const Component = path ? \"a\" : \"div\";\n\n const hasErrorOrWarning =\n supportLabelType === \"error\" || supportLabelType === \"warning\";\n const hasSuccess = supportLabelType === \"success\";\n\n const renderFeedbackElement = () => {\n if (!hasErrorOrWarning && !hasSuccess) {\n return (\n <SupportLabel\n className=\"jkl-file__support-label jkl-body\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n );\n }\n\n if (hasSuccess)\n return (\n <SuccessIcon\n variant=\"small\"\n aria-label=\"Filen ble lastet opp uten feil\"\n />\n );\n\n return null;\n };\n\n const fileComponent = (\n <div id={id} className=\"jkl-file\">\n <Component\n className={cn(\"jkl-file__content\", {\n \"jkl-file__content--error\": supportLabelType === \"error\",\n \"jkl-file__content--warning\":\n supportLabelType === \"warning\",\n })}\n href={path}\n target={path ? \"_blank\" : undefined}\n >\n <Thumbnail\n fileName={fileName}\n fileType={fileType}\n file={file}\n path={path}\n state={state}\n >\n {children}\n </Thumbnail>\n <div>\n <p className=\"jkl-file__name\">{fileName}</p>\n <p className=\"jkl-file__description\">\n <span>{formatBytes(fileSize)}</span>\n {renderFeedbackElement()}\n </p>\n {supportLabel && hasErrorOrWarning && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n )}\n </div>\n </Component>\n {onRemove && (\n <IconButton\n className=\"jkl-file__delete\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n >\n <TrashCanIcon />\n </IconButton>\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["File","props","children","fileName","fileType","fileSize","path","file","supportLabel","supportLabelType","state","onRemove","id","useId","supportId","context","useFileInputContext","hasErrorOrWarning","hasSuccess","fileComponent","jsxs","className","cn","href","target","jsx","Thumbnail","formatBytes","SuccessIcon","variant","SupportLabel","label","labelType","IconButton","onClick","title","TrashCanIcon"],"mappings":"8yDAwBa,MAAAA,EAAuBC,IAC1B,MACFC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,aAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,SAAAA,GACAV,EAEEW,EAAKC,EAAM,oBACXC,EAAYF,EAAK,WAEjBG,EAAUC,IAIVC,EACmB,UAArBR,GAAqD,YAArBA,EAC9BS,EAAkC,YAArBT,EAyBbU,EACFC,EAAC,MAAI,CAAAR,GAAAA,EAAQS,UAAU,WACnBnB,SAAA,CAAAkB,EA/BUd,EAAO,IAAM,MA+BtB,CACGe,UAAWC,EAAG,oBAAqB,CAC/B,2BAAiD,UAArBb,EAC5B,6BACyB,YAArBA,IAERc,KAAMjB,EACNkB,OAAQlB,EAAO,cAAW,EAE1BJ,SAAA,CAAAuB,EAACC,EAAA,CACGvB,SAAAA,EACAC,SAAAA,EACAG,KAAAA,EACAD,KAAAA,EACAI,MAAAA,EAECR,SAAAA,MAEJ,MACG,CAAAA,SAAA,CAACuB,EAAA,IAAA,CAAEJ,UAAU,iBAAkBnB,SAASC,IACxCiB,EAAC,IAAE,CAAAC,UAAU,wBACTnB,SAAA,CAACuB,EAAA,OAAA,CAAMvB,SAAYyB,EAAAtB,KA7C9BY,GAAsBC,EAWvBA,EAEIO,EAACG,EAAA,CACGC,QAAQ,QACR,aAAW,mCAIhB,KAjBCJ,EAACK,EAAA,CACGT,UAAU,mCACVT,GAAIE,EACJiB,MAAOvB,EACPwB,UAAWvB,OA0CVD,GAAgBS,GACbQ,EAACK,EAAA,CACGT,UAAU,0BACVT,GAAIE,EACJiB,MAAOvB,EACPwB,UAAWvB,UAK1BE,GACGc,EAACQ,EAAA,CACGZ,UAAU,mBACVa,QAASvB,EACTwB,MAAO,SAAShC,IAEhBD,WAACkC,EAAa,SAMvBrB,OAAAA,EAAUU,EAAC,KAAI,CAAAvB,SAAAiB,IAAsBA,CAAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FieldGroupProps } from '../../components/input-group/FieldGroup.js';
|
|
3
|
+
import { Density } from '../../core/types.js';
|
|
4
|
+
import { FileInputFile } from './types.js';
|
|
5
|
+
export interface FileInputProps extends Omit<FieldGroupProps, "onChange"> {
|
|
6
|
+
className?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
density?: Density;
|
|
9
|
+
/**
|
|
10
|
+
* En string som begrenser hvilke filtyper som kan velges.
|
|
11
|
+
*
|
|
12
|
+
* Flere filtyper kan defineres som en kommaseparert liste.
|
|
13
|
+
*
|
|
14
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept
|
|
15
|
+
*/
|
|
16
|
+
accept?: "image/*" | ".pdf" | "image/*,.pdf" | HTMLInputElement["accept"];
|
|
17
|
+
maxSizeBytes?: number;
|
|
18
|
+
/**
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
value: FileInputFile[];
|
|
23
|
+
variant?: "flexible" | "small";
|
|
24
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLDivElement>, files: FileInputFile[]) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const FileInput: React.ForwardRefExoticComponent<FileInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import i from"classnames";import{forwardRef as t}from"react";import{FieldGroup as a}from"../input-group/FieldGroup.js";import{Dropzone as n}from"./internal/Dropzone.js";import{FileInputContextProvider as s}from"./internal/fileInputContext.js";import{Input as r}from"./internal/Input.js";const o=t(((t,o)=>{const{accept:c,className:p,children:m,id:f,value:u,density:d,multiple:h=!0,maxSizeBytes:j,onChange:g,variant:x,...k}=t,y=u.length>0;return e(s,"small"===x?{context:{accept:c,onChange:g,maxSizeBytes:j,files:u},children:l(a,{className:i("jkl-file-input","jkl-file-input--small",p,{"jkl-file-input--has-files":y}),"data-layout-density":d||"compact",...k,children:[e(n,{children:e("div",{className:"jkl-file-input__call-to-action",children:e(r,{id:f,label:"Legg til fil",multiple:h,ref:o})})}),u.length>0&&e("ul",{className:"jkl-file-input__files",children:m})]})}:{context:{accept:c,onChange:g,maxSizeBytes:j,files:u},children:e(a,{className:i("jkl-file-input",p,{"jkl-file-input--has-files":y}),"data-layout-density":d,...k,children:l(n,{children:[u.length>0&&e("ul",{className:"jkl-file-input__files",children:m}),e("div",{className:"jkl-file-input__call-to-action",children:e(r,{id:f,label:h&&y?"Legg til flere filer":"Legg til fil",multiple:h,ref:o})})]})})})}));o.displayName="FileInput";export{o as FileInput};
|
|
2
|
+
//# sourceMappingURL=FileInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileInput.js","sources":["../../../../src/components/file-input/FileInput.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport React, { forwardRef } from \"react\";\nimport {\n FieldGroup,\n type FieldGroupProps,\n} from \"../../components/input-group/FieldGroup.js\";\nimport { type Density } from \"../../core/types.js\";\nimport { Dropzone } from \"./internal/Dropzone.js\";\nimport { FileInputContextProvider } from \"./internal/fileInputContext.js\";\nimport { Input } from \"./internal/Input.js\";\nimport { FileInputFile } from \"./types.js\";\n\nexport interface FileInputProps extends Omit<FieldGroupProps, \"onChange\"> {\n className?: string;\n id?: string;\n density?: Density;\n /**\n * En string som begrenser hvilke filtyper som kan velges.\n *\n * Flere filtyper kan defineres som en kommaseparert liste.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept\n */\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n /**\n * @default true\n */\n multiple?: boolean;\n value: FileInputFile[];\n variant?: \"flexible\" | \"small\";\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n}\n\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const {\n accept,\n className,\n children,\n id,\n value,\n density,\n multiple = true,\n maxSizeBytes,\n onChange,\n variant,\n ...rest\n } = props;\n\n const hasFiles = value.length > 0;\n\n if (variant === \"small\") {\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={cn(\n \"jkl-file-input\",\n \"jkl-file-input--small\",\n className,\n {\n \"jkl-file-input--has-files\": hasFiles,\n },\n )}\n data-layout-density={density ? density : \"compact\"}\n {...rest}\n >\n <Dropzone>\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label=\"Legg til fil\"\n multiple={multiple}\n ref={ref}\n />\n </div>\n </Dropzone>\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n </FieldGroup>\n </FileInputContextProvider>\n );\n }\n\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={cn(\"jkl-file-input\", className, {\n \"jkl-file-input--has-files\": hasFiles,\n })}\n data-layout-density={density}\n {...rest}\n >\n <Dropzone>\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label={\n multiple && hasFiles\n ? \"Legg til flere filer\"\n : \"Legg til fil\"\n }\n multiple={multiple}\n ref={ref}\n />\n </div>\n </Dropzone>\n </FieldGroup>\n </FileInputContextProvider>\n );\n },\n);\n\nFileInput.displayName = \"FileInput\";\n"],"names":["FileInput","forwardRef","props","ref","accept","className","children","id","value","density","multiple","maxSizeBytes","onChange","variant","rest","hasFiles","length","jsx","FileInputContextProvider","context","files","jsxs","FieldGroup","cn","Dropzone","Input","label","displayName"],"mappings":"iVAuCO,MAAMA,EAAYC,GACrB,CAACC,EAAOC,KACE,MACFC,OAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,GAAAA,EACAC,MAAAA,EACAC,QAAAA,EACAC,SAAAA,GAAW,EACXC,aAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,GACHZ,EAEEa,EAAWP,EAAMQ,OAAS,EAE5BH,OAEII,EAACC,EAFO,UAAZL,EAEK,CACGM,QAAS,CAAEf,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcS,MAAOZ,GAElDF,SAAAe,EAACC,EAAA,CACGjB,UAAWkB,EACP,iBACA,wBACAlB,EACA,CACI,4BAA6BU,IAGrC,sBAAqBN,GAAoB,aACrCK,EAEJR,SAAA,CAAAW,EAACO,EACG,CAAAlB,SAAAW,EAAC,MAAI,CAAAZ,UAAU,iCACXC,SAAAW,EAACQ,EAAA,CACGlB,GAAAA,EACAmB,MAAM,eACNhB,SAAAA,EACAP,IAAAA,QAIXK,EAAMQ,OAAS,KACX,KAAG,CAAAX,UAAU,wBACTC,SAAAA,QASpB,CACGa,QAAS,CAAEf,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcS,MAAOZ,GAElDF,SAAAW,EAACK,EAAA,CACGjB,UAAWkB,EAAG,iBAAkBlB,EAAW,CACvC,4BAA6BU,IAEjC,sBAAqBN,KACjBK,EAEJR,WAACkB,EACI,CAAAlB,SAAA,CAAAE,EAAMQ,OAAS,GACZC,EAAC,KAAG,CAAAZ,UAAU,wBACTC,SAAAA,IAGTW,EAAC,MAAI,CAAAZ,UAAU,iCACXC,SAAAW,EAACQ,EAAA,CACGlB,GAAAA,EACAmB,MACIhB,GAAYK,EACN,uBACA,eAEVL,SAAAA,EACAP,IAAAA,YAIhB,IAMhBH,EAAU2B,YAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WithChildren } from '../../../core/types.js';
|
|
3
|
+
interface DropzoneProps extends WithChildren {
|
|
4
|
+
}
|
|
5
|
+
export declare const Dropzone: React.ForwardRefExoticComponent<DropzoneProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r from"classnames";import{forwardRef as t,useState as a}from"react";import{useFileInputContext as n}from"./fileInputContext.js";import{validateFile as o}from"./validateFile.js";const i=t(((t,i)=>{const{children:s,...l}=t,[p,f]=a(""),d=n();if(!d)return e("p",{children:"Dropzone must be placed inside a FileInputContextProvider."});const{maxSizeBytes:m,accept:u,onChange:c}=d;return e("div",{...l,ref:i,className:r("jkl-file-input__dropzone",p),onDragEnter:e=>{f("jkl-file-input__dropzone--enter"),e.preventDefault()},onDragOver:e=>{f("jkl-file-input__dropzone--enter"),e.preventDefault()},onDrop:e=>{e.preventDefault(),f(""),e.dataTransfer.files&&c(e,[...e.dataTransfer.files].map((e=>({file:e,state:"SELECTED",validation:o(e,u,m),uploadProgress:0}))))},onDragLeave:e=>{f(""),e.preventDefault()},children:s})}));i.displayName="Dropzone";export{i as Dropzone};
|
|
2
|
+
//# sourceMappingURL=Dropzone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dropzone.js","sources":["../../../../../src/components/file-input/internal/Dropzone.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport React, { forwardRef, useState } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface DropzoneProps extends WithChildren {}\n\nexport const Dropzone = forwardRef<HTMLDivElement, DropzoneProps>(\n (props, ref) => {\n const { children, ...rest } = props;\n const [onDragClassName, setOnDragClassName] = useState<string>(\"\");\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>\n Dropzone must be placed inside a FileInputContextProvider.\n </p>\n );\n }\n const { maxSizeBytes, accept, onChange } = context;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={cn(\"jkl-file-input__dropzone\", onDragClassName)}\n onDragEnter={(e) => {\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDragOver={(e) => {\n /* Prevent browser from opening file in a new tab */\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDrop={(e) => {\n e.preventDefault();\n setOnDragClassName(\"\");\n\n if (e.dataTransfer.files) {\n onChange(\n e,\n [...e.dataTransfer.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n onDragLeave={(e) => {\n setOnDragClassName(\"\");\n e.preventDefault();\n }}\n >\n {children}\n </div>\n );\n },\n);\n\nDropzone.displayName = \"Dropzone\";\n"],"names":["Dropzone","forwardRef","props","ref","children","rest","onDragClassName","setOnDragClassName","useState","context","useFileInputContext","jsx","maxSizeBytes","accept","onChange","className","cn","onDragEnter","e","preventDefault","onDragOver","onDrop","dataTransfer","files","map","file","state","validation","validateFile","uploadProgress","onDragLeave","displayName"],"mappings":"gOASO,MAAMA,EAAWC,GACpB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,KAAaC,GAASH,GACvBI,EAAiBC,GAAsBC,EAAiB,IAEzDC,EAAUC,IAChB,IAAKD,EAEG,OAAAE,EAAC,KAAEP,SAEH,+DAGR,MAAQQ,aAAAA,EAAcC,OAAAA,EAAQC,SAAAA,GAAaL,EAGvC,OAAAE,EAAC,MAAA,IACON,EACJF,IAAAA,EACAY,UAAWC,EAAG,2BAA4BV,GAC1CW,YAAcC,IACVX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBC,WAAaF,IAETX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBE,OAASH,IACLA,EAAEC,iBACFZ,EAAmB,IAEfW,EAAEI,aAAaC,OACfT,EACII,EACA,IAAIA,EAAEI,aAAaC,OAAOC,KACrBC,IAAU,CACPA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EACRH,EACAZ,EACAD,GAEJiB,eAAgB,MAExB,EAIZC,YAAcZ,IACVX,EAAmB,IACnBW,EAAEC,gBAAe,EAGpBf,SAAAA,GAAA,IAMjBJ,EAAS+B,YAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import{forwardRef as s}from"react";import{useId as a}from"../../../hooks/useId/useId.js";import{formatBytes as r}from"../../../utilities/formatters/bytes/formatBytes.js";import{useFileInputContext as l}from"./fileInputContext.js";import{validateFile as o}from"./validateFile.js";const n=s(((s,n)=>{const{multiple:p,id:m,label:f,...d}=s,u=a(m||"jkl-file-input",{generateSuffix:!m}),c=u+"-description",j=p?"filer":"fil",h=l();if(!h)return e("p",{children:"Input must be placed inside a FileInputContextProvider."});const{accept:x,maxSizeBytes:y,onChange:I,files:b}=h;return t(i,{children:[e("label",{className:"jkl-button jkl-button--secondary",htmlFor:u,children:f}),e("input",{...d,ref:n,id:u,accept:x,"aria-describedby":y?c:void 0,className:"jkl-sr-only",type:"file",multiple:p,onChange:e=>{e.target.files&&I(e,[...e.target.files].map((e=>({file:e,state:"SELECTED",validation:o(e,x,y),uploadProgress:0}))))}}),0===b.length&&t("p",{children:["eller slipp ",j," her"]}),typeof y<"u"&&t("div",{id:c,className:"jkl-file-input__max-size-text",children:["Maks ",r(y)," per fil"]})]})}));n.displayName="Input";export{n as Input};
|
|
2
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../../../src/components/file-input/internal/Input.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { useId } from \"../../../hooks/useId/useId.js\";\nimport { formatBytes } from \"../../../utilities/formatters/bytes/formatBytes.js\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface FileInputProps {\n id?: string;\n label: string;\n multiple: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const { multiple, id: idProp, label, ...rest } = props;\n\n const id = useId(idProp || \"jkl-file-input\", {\n generateSuffix: !idProp,\n });\n const maxSizeDescriptionId = id + \"-description\";\n const descriptor = multiple ? \"filer\" : \"fil\";\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>Input must be placed inside a FileInputContextProvider.</p>\n );\n }\n const { accept, maxSizeBytes, onChange, files } = context;\n\n return (\n <>\n <label\n className=\"jkl-button jkl-button--secondary\"\n htmlFor={id}\n >\n {label}\n </label>\n <input\n {...rest}\n ref={ref}\n id={id}\n accept={accept}\n aria-describedby={\n maxSizeBytes ? maxSizeDescriptionId : undefined\n }\n className=\"jkl-sr-only\"\n type=\"file\"\n multiple={multiple}\n onChange={(e) => {\n if (e.target.files) {\n onChange(\n e,\n [...e.target.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n />\n {files.length === 0 && <p>eller slipp {descriptor} her</p>}\n {typeof maxSizeBytes !== \"undefined\" && (\n <div\n id={maxSizeDescriptionId}\n className=\"jkl-file-input__max-size-text\"\n >\n Maks {formatBytes(maxSizeBytes)} per fil\n </div>\n )}\n </>\n );\n },\n);\n\nInput.displayName = \"Input\";\n"],"names":["Input","forwardRef","props","ref","multiple","id","idProp","label","rest","useId","generateSuffix","maxSizeDescriptionId","descriptor","context","useFileInputContext","jsx","children","accept","maxSizeBytes","onChange","files","jsxs","Fragment","className","htmlFor","type","e","target","map","file","state","validation","validateFile","uploadProgress","length","formatBytes","displayName"],"mappings":"uVAaO,MAAMA,EAAQC,GACjB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,EAAUC,GAAIC,EAAQC,MAAAA,KAAUC,GAASN,EAE3CG,EAAKI,EAAMH,GAAU,iBAAkB,CACzCI,gBAAiBJ,IAEfK,EAAuBN,EAAK,eAC5BO,EAAaR,EAAW,QAAU,MAElCS,EAAUC,IAChB,IAAKD,EAEG,OAAAE,EAAC,KAAEC,SAAuD,4DAG5D,MAAEC,OAAAA,EAAQC,aAAAA,EAAcC,SAAAA,EAAUC,MAAAA,GAAUP,EAElD,OAEQQ,EAAAC,EAAA,CAAAN,SAAA,CAAAD,EAAC,QAAA,CACGQ,UAAU,mCACVC,QAASnB,EAERW,SAAAT,IAELQ,EAAC,QAAA,IACOP,EACJL,IAAAA,EACAE,GAAAA,EACAY,OAAAA,EACA,mBACIC,EAAeP,OAAuB,EAE1CY,UAAU,cACVE,KAAK,OACLrB,SAAAA,EACAe,SAAWO,IACHA,EAAEC,OAAOP,OACTD,EACIO,EACA,IAAIA,EAAEC,OAAOP,OAAOQ,KACfC,IAAU,CACPA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EACRH,EACAZ,EACAC,GAEJe,eAAgB,MAExB,IAKE,IAAjBb,EAAMc,QAAgBb,EAAC,IAAE,CAAAL,SAAA,CAAA,eAAaJ,EAAW,iBAC1CM,EAAiB,KACrBG,EAAC,MAAA,CACGhB,GAAIM,EACJY,UAAU,gCACbP,SAAA,CAAA,QACSmB,EAAYjB,GAAc,gBAG5C,IAKZlB,EAAMoC,YAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { WithOptionalChildren } from '../../../core/types.js';
|
|
3
|
+
import { FileInputFileState } from '../types.js';
|
|
4
|
+
export interface ThumbnailProps extends WithOptionalChildren {
|
|
5
|
+
fileName: string;
|
|
6
|
+
fileType: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
file?: File;
|
|
9
|
+
state?: FileInputFileState;
|
|
10
|
+
}
|
|
11
|
+
export declare const Thumbnail: FC<ThumbnailProps>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as l}from"react/jsx-runtime";import a from"classnames";const i=i=>{const{fileName:s,fileType:t,path:r,file:m,state:c,children:n}=i,h=a("jkl-file__thumbnail",{"jkl-file__thumbnail--selected":"SELECTED"===c,"jkl-file__thumbnail--uploading":"UPLOADING"===c});return t.startsWith("image/")?e("div",{className:"jkl-file__thumbnail-wrapper",children:[l("img",{className:h,src:m?URL.createObjectURL(m):r,alt:""}),n]}):l("div",{className:h,children:l("p",{children:s.split(".").at(-1)})})};export{i as Thumbnail};
|
|
2
|
+
//# sourceMappingURL=Thumbnail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thumbnail.js","sources":["../../../../../src/components/file-input/internal/Thumbnail.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport React, { FC } from \"react\";\nimport type { WithOptionalChildren } from \"../../../core/types.js\";\nimport { FileInputFileState } from \"../types.js\";\n\nexport interface ThumbnailProps extends WithOptionalChildren {\n fileName: string;\n fileType: string;\n path?: string;\n file?: File;\n state?: FileInputFileState;\n}\n\nexport const Thumbnail: FC<ThumbnailProps> = (props) => {\n const { fileName, fileType, path, file, state, children } = props;\n\n const classNames = cn(\"jkl-file__thumbnail\", {\n \"jkl-file__thumbnail--selected\": state === \"SELECTED\",\n \"jkl-file__thumbnail--uploading\": state === \"UPLOADING\",\n });\n\n if (fileType.startsWith(\"image/\")) {\n return (\n <div className=\"jkl-file__thumbnail-wrapper\">\n <img\n className={classNames}\n src={file ? URL.createObjectURL(file) : path}\n alt=\"\"\n />\n {children}\n </div>\n );\n }\n\n return (\n <div className={classNames}>\n <p>{fileName.split(\".\").at(-1)}</p>\n </div>\n );\n};\n"],"names":["Thumbnail","props","fileName","fileType","path","file","state","children","classNames","cn","startsWith","jsxs","className","jsx","src","URL","createObjectURL","alt","split","at"],"mappings":"4EAaa,MAAAA,EAAiCC,IAC1C,MAAQC,SAAAA,EAAUC,SAAAA,EAAUC,KAAAA,EAAMC,KAAAA,EAAMC,MAAAA,EAAOC,SAAAA,GAAaN,EAEtDO,EAAaC,EAAG,sBAAuB,CACzC,gCAA2C,aAAVH,EACjC,iCAA4C,cAAVA,IAGlCH,OAAAA,EAASO,WAAW,UAEhBC,EAAC,MAAI,CAAAC,UAAU,8BACXL,SAAA,CAAAM,EAAC,MAAA,CACGD,UAAWJ,EACXM,IAAKT,EAAOU,IAAIC,gBAAgBX,GAAQD,EACxCa,IAAI,KAEPV,KAMRM,EAAA,MAAA,CAAID,UAAWJ,EACZD,SAACM,EAAA,IAAA,CAAGN,SAASL,EAAAgB,MAAM,KAAKC,IAAK,MACjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WithChildren } from '../../../core/types.js';
|
|
3
|
+
import { FileInputFile } from '../types.js';
|
|
4
|
+
type FileInputContext = {
|
|
5
|
+
accept?: "image/*" | ".pdf" | "image/*,.pdf" | HTMLInputElement["accept"];
|
|
6
|
+
maxSizeBytes?: number;
|
|
7
|
+
files: FileInputFile[];
|
|
8
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLDivElement>, files: FileInputFile[]) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const useFileInputContext: () => FileInputContext | null;
|
|
11
|
+
export interface FileInputContextProviderProps extends WithChildren {
|
|
12
|
+
context: FileInputContext;
|
|
13
|
+
}
|
|
14
|
+
export declare const FileInputContextProvider: React.FC<FileInputContextProviderProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createContext as t,useContext as r}from"react";const o=t(null),n=()=>r(o),s=({context:t,children:r})=>e(o.Provider,{value:t,children:r});export{s as FileInputContextProvider,n as useFileInputContext};
|
|
2
|
+
//# sourceMappingURL=fileInputContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileInputContext.js","sources":["../../../../../src/components/file-input/internal/fileInputContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\n\ntype FileInputContext = {\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n files: FileInputFile[];\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n};\n\nconst fileInputContext = createContext<FileInputContext | null>(null);\n\nexport const useFileInputContext = (): FileInputContext | null =>\n useContext(fileInputContext);\n\nexport interface FileInputContextProviderProps extends WithChildren {\n context: FileInputContext;\n}\n\nexport const FileInputContextProvider: React.FC<\n FileInputContextProviderProps\n> = ({ context, children }) => (\n <fileInputContext.Provider value={context}>\n {children}\n </fileInputContext.Provider>\n);\n"],"names":["fileInputContext","createContext","useFileInputContext","useContext","FileInputContextProvider","context","children","jsx","Provider","value"],"mappings":"8FAgBA,MAAMA,EAAmBC,EAAuC,MAEnDC,EAAsB,IAC/BC,EAAWH,GAMFI,EAET,EAAGC,QAAAA,EAASC,SAAAA,KACXC,EAAAP,EAAiBQ,SAAjB,CAA0BC,MAAOJ,EAC7BC,SAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{formatBytes as e}from"../../../utilities/formatters/bytes/formatBytes.js";function t(t,s="",a){var i;const l=s.split(",").map((e=>e.toLowerCase())).map((e=>e.replaceAll("*",""))).map((e=>e.trim()));let m=0===l.length;return m=l.reduce(((e,s)=>e||t.type.includes(s)||t.name.endsWith(s)),m),m?typeof a<"u"&&t.size>a?{type:"TOO_LARGE",message:`Filen er ${e(t.size)}, men kan maksimalt være ${e(a)}`}:void 0:{type:"WRONG_TYPE",message:`Filtypen ${(null==(i=t.name)?void 0:i.split(".")[1])||""} støttes ikke`}}export{t as validateFile};
|
|
2
|
+
//# sourceMappingURL=validateFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateFile.js","sources":["../../../../../src/components/file-input/internal/validateFile.ts"],"sourcesContent":["import { formatBytes } from \"../../../utilities/formatters/bytes/formatBytes.js\";\nimport type { FileInputFileValidation } from \"../types.js\";\n\nexport function validateFile(\n file: File,\n accept = \"\",\n maxSizeBytes?: number,\n): FileInputFileValidation | undefined {\n const acceptStrings = accept\n .split(\",\")\n .map((s) => s.toLowerCase())\n .map((s) => s.replaceAll(\"*\", \"\"))\n .map((s) => s.trim());\n\n let isValidFormat = acceptStrings.length === 0;\n\n isValidFormat = acceptStrings.reduce(\n (found, acceptString) =>\n found ||\n file.type.includes(acceptString) ||\n file.name.endsWith(acceptString),\n isValidFormat,\n );\n\n if (!isValidFormat) {\n return {\n type: \"WRONG_TYPE\",\n message: `Filtypen ${file.name?.split(\".\")[1] || \"\"} støttes ikke`,\n };\n }\n\n if (typeof maxSizeBytes != \"undefined\" && file.size > maxSizeBytes) {\n return {\n type: \"TOO_LARGE\",\n message: `Filen er ${formatBytes(\n file.size,\n )}, men kan maksimalt være ${formatBytes(maxSizeBytes)}`,\n };\n }\n\n return undefined;\n}\n"],"names":["validateFile","file","accept","maxSizeBytes","acceptStrings","split","map","s","toLowerCase","replaceAll","trim","isValidFormat","length","reduce","found","acceptString","type","includes","name","endsWith","size","message","formatBytes","_a"],"mappings":"iFAGO,SAASA,EACZC,EACAC,EAAS,GACTC,SAEMC,MAAAA,EAAgBF,EACjBG,MAAM,KACNC,KAAKC,GAAMA,EAAEC,gBACbF,KAAKC,GAAMA,EAAEE,WAAW,IAAK,MAC7BH,KAAKC,GAAMA,EAAEG,SAEdC,IAAAA,EAAyC,IAAzBP,EAAcQ,OAUlC,OARAD,EAAgBP,EAAcS,QAC1B,CAACC,EAAOC,IACJD,GACAb,EAAKe,KAAKC,SAASF,IACnBd,EAAKiB,KAAKC,SAASJ,IACvBJ,GAGCA,SAOMR,EAAgB,KAAeF,EAAKmB,KAAOjB,EAC3C,CACHa,KAAM,YACNK,QAAS,YAAYC,EACjBrB,EAAKmB,iCACoBE,EAAYnB,WALjD,EANW,CACHa,KAAM,aACNK,QAAS,aAAY,OAAAE,EAAAtB,EAAKiB,aAALK,EAAWlB,MAAM,KAAK,KAAM,kBAc7D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FileInputFileValidation {
|
|
2
|
+
type: "TOO_LARGE" | "WRONG_TYPE";
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export type FileInputFileState = "SELECTED" | "UPLOADING" | "UPLOAD_ERROR" | "UPLOAD_SUCCESS";
|
|
6
|
+
export interface FileInputFile {
|
|
7
|
+
file: File;
|
|
8
|
+
validation?: FileInputFileValidation;
|
|
9
|
+
state: FileInputFileState;
|
|
10
|
+
uploadProgress: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hjelpefunksjon for å laste opp filer med progress-bar
|
|
3
|
+
*
|
|
4
|
+
* @param {string} url Endepunktet som skal lastes opp til
|
|
5
|
+
* @param {FormData} data FormData med filen som skal lastes opp
|
|
6
|
+
* @param progress Callback som blir kalt med oppdatert progresjon
|
|
7
|
+
* @param {Record<string, string>} headers Eventuelle headers som skal sendes
|
|
8
|
+
* med opplasingen. Her kan du f.eks. sende med CSRF-verdier.
|
|
9
|
+
* @returns {T} Svaret fra endepunktet
|
|
10
|
+
*/
|
|
11
|
+
export declare function upload<T>(url: string, data: FormData, progress: (progress: number) => void, headers?: Record<string, string>): Promise<T>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function e(e,t,r,n){const s=new XMLHttpRequest;return new Promise(((a,o)=>{s.upload.addEventListener("progress",(e=>{e.lengthComputable&&r&&r(e.loaded/e.total*100)})),s.addEventListener("load",(e=>{s.status>=400&&o(e),a(e)})),s.addEventListener("error",(e=>{o(e)})),s.addEventListener("abort",(e=>{o(e)})),s.open("POST",e),Object.entries(n||{}).forEach((([e,t])=>{s.setRequestHeader(e,t)})),s.send(t)})).then((e=>JSON.parse(s.responseText)),(()=>{throw new Error(s.statusText)}))}export{e as upload};
|
|
2
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/file-input/utils.ts"],"sourcesContent":["/**\n * Hjelpefunksjon for å laste opp filer med progress-bar\n *\n * @param {string} url Endepunktet som skal lastes opp til\n * @param {FormData} data FormData med filen som skal lastes opp\n * @param progress Callback som blir kalt med oppdatert progresjon\n * @param {Record<string, string>} headers Eventuelle headers som skal sendes\n * med opplasingen. Her kan du f.eks. sende med CSRF-verdier.\n * @returns {T} Svaret fra endepunktet\n */\nexport async function upload<T>(\n url: string,\n data: FormData,\n progress: (progress: number) => void,\n headers?: Record<string, string>,\n): Promise<T> {\n // I skrivende stund er det ikke mulig å hente progress med fetch. Derfor bruker vi XMLHttpRequest.\n const xhr = new XMLHttpRequest();\n const request = new Promise<ProgressEvent<XMLHttpRequestEventTarget>>(\n (resolve, reject) => {\n xhr.upload.addEventListener(\"progress\", (e) => {\n if (e.lengthComputable && progress) {\n progress((e.loaded / e.total) * 100);\n }\n });\n\n xhr.addEventListener(\"load\", (e) => {\n if (xhr.status >= 400) {\n reject(e);\n }\n resolve(e);\n });\n\n xhr.addEventListener(\"error\", (e) => {\n reject(e);\n });\n\n xhr.addEventListener(\"abort\", (e) => {\n reject(e);\n });\n\n xhr.open(\"POST\", url);\n\n Object.entries(headers || {}).forEach(([header, value]) => {\n xhr.setRequestHeader(header, value);\n });\n\n xhr.send(data);\n },\n ).then(\n (e) => {\n const response: T = JSON.parse(xhr.responseText);\n return response;\n },\n () => {\n throw new Error(xhr.statusText);\n },\n );\n\n return request;\n}\n"],"names":["async","upload","url","data","progress","headers","xhr","XMLHttpRequest","Promise","resolve","reject","addEventListener","e","lengthComputable","loaded","total","status","open","Object","entries","forEach","header","value","setRequestHeader","send","then","JSON","parse","responseText","Error","statusText"],"mappings":"AAUAA,eAAsBC,EAClBC,EACAC,EACAC,EACAC,GAGMC,MAAAA,EAAM,IAAIC,eA0CT,OAzCS,IAAIC,SAChB,CAACC,EAASC,KACNJ,EAAIL,OAAOU,iBAAiB,YAAaC,IACjCA,EAAEC,kBAAoBT,GACtBA,EAAUQ,EAAEE,OAASF,EAAEG,MAAS,IAAG,IAIvCT,EAAAK,iBAAiB,QAASC,IACtBN,EAAIU,QAAU,KACdN,EAAOE,GAEXH,EAAQG,EAAC,IAGTN,EAAAK,iBAAiB,SAAUC,IAC3BF,EAAOE,EAAC,IAGRN,EAAAK,iBAAiB,SAAUC,IAC3BF,EAAOE,EAAC,IAGRN,EAAAW,KAAK,OAAQf,GAEVgB,OAAAC,QAAQd,GAAW,CAAE,GAAEe,SAAQ,EAAEC,EAAQC,MACxChB,EAAAiB,iBAAiBF,EAAQC,EAAK,IAGtChB,EAAIkB,KAAKrB,EAAI,IAEnBsB,MACGb,GACuBc,KAAKC,MAAMrB,EAAIsB,gBAGvC,KACU,MAAA,IAAIC,MAAMvB,EAAIwB,WAAU,GAK1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{c as r}from"../../../clsx-BeLtu-UY.js";import{forwardRef as o,useState as a,useCallback as l,useMemo as s,useRef as i,useEffect as u}from"react";import{useAnimatedHeight as c}from"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import{useId as
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{c as r}from"../../../clsx-BeLtu-UY.js";import{forwardRef as o,useState as a,useCallback as l,useMemo as s,useRef as i,useEffect as u}from"react";import{useAnimatedHeight as c}from"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import{useId as d}from"../../hooks/useId/useId.js";import{useListNavigation as p}from"../../hooks/useListNavigation/useListNavigation.js";import{usePreviousValue as v}from"../../hooks/usePreviousValue/usePreviousValue.js";import{getValuePair as f}from"../../utilities/valuePair.js";import{ArrowVerticalAnimated as m}from"../icon/icons/animated/ArrowVerticalAnimated.js";import{InputGroup as b}from"../input-group/InputGroup.js";import{focusSelected as g,toLower as h}from"./select-utils.js";const k=()=>{},y=o(((o,y)=>{const{id:j,name:w,items:_,value:P,label:D,labelProps:E,onChange:L,onBlur:$,onFocus:x,className:N,helpLabel:A,errorLabel:C,invalid:F,searchable:S=!1,inline:V=!1,defaultPrompt:T="Velg",density:I,width:K,maxShownOptions:B=5,style:H,tooltipProps:M,...O}=o,G=d(j||"jkl-select",{generateSuffix:!j}),R=`${G}_label`,q=`${G}_button`,U=`${G}_search-input`,[z,J]=a(!1),Q=l((()=>{J((e=>!e))}),[]),W=!!S,X=W&&z,[Y,Z]=a(""),ee=l((e=>!!e.label.toLowerCase().includes(Y.toLowerCase())||"function"==typeof S&&S(Y,e)),[S,Y]),te=s((()=>_.map(f).map((e=>{const t=!W||""===Y||ee(e);return{...e,visible:t}}))),[_,W,Y,ee]),ne=s((()=>!(typeof P>"u")&&_.some((e=>"string"==typeof e?e===P:e.value===P))),[P,_]),[re,oe]=a(ne&&void 0!==P?P:""),ae=""!==re,le=s((()=>{var e;return(null==(e=te.find((e=>e.value===re)))?void 0:e.label)||T}),[te,re,T]),se=i(null),ie=l((e=>{se.current=e,y&&("function"==typeof y?y(e):y.current=e),e&&oe(e.value)}),[se,y]),ue=v(P);u((()=>{P!==ue&&oe(typeof P>"u"||!ne?"":P)}),[oe,P,ue,ne]);const ce=l((e=>{const t=e.value;Z(""),oe(t),Q()}),[Z,oe,Q]),de=v(re);u((()=>{typeof de>"u"||de===re||re===P||(L&&L({type:"change",target:{name:w,value:re}}),se.current&&se.current.dispatchEvent(new Event("change",{bubbles:!0})))}),[L,w,P,re,de]);const pe=i(null),ve=i(!1),fe=i(null),me=i(null),be=l(((e,t)=>{if(e&&!W){const e=t.current;e&&g(e,re)}else e?fe.current&&fe.current.focus():ve.current&&me.current&&me.current.focus()}),[W,re]),[ge]=c(z,{onFirstVisible:be,onTransitionEnd:be});p({ref:ge});const he=l((()=>{var e;W&&Z(""),$&&($({type:"blur",target:{name:w,value:re}}),null==(e=se.current)||e.dispatchEvent(new Event("focusout",{bubbles:!0}))),ve.current=!1,J(!1)}),[$,Z,J,W,w,re]),ke=l((e=>{const t=pe.current;t&&t.contains(e.relatedTarget)||he()}),[he]),ye=l((()=>{ve.current||(x&&x({type:"change",target:{name:w,value:re}}),ve.current=!0)}),[x,re,w]),je=l((e=>{e.target.focus({preventScroll:!0})}),[]);u((()=>{const e=se.current,t=fe.current,n=me.current,r=pe.current;return null==e||e.addEventListener("focus",(()=>{X?null==t||t.focus():null==n||n.focus()})),null==e||e.addEventListener("blur",(function(e){r&&r.contains(e.relatedTarget)&&e.preventDefault()})),()=>{null==e||e.removeEventListener("focus",(()=>{X?null==t||t.focus():null==n||n.focus()})),null==e||e.removeEventListener("blur",(function(e){r&&r.contains(e.relatedTarget)&&e.preventDefault()}))}}),[X]);const we=l((e=>{"ArrowDown"!==e.key&&" "!==e.key||z?"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),J(!1)):(e.preventDefault(),e.stopPropagation(),J(!0))}),[J,z]),_e=l((e=>{if("ArrowDown"===e.key){e.preventDefault(),e.stopPropagation();const t=ge.current;t&&g(t,W?void 0:re)}else if("Escape"===e.key)e.preventDefault(),e.stopPropagation(),J(!1);else if("Tab"!==e.key||e.shiftKey)"Enter"===e.key&&z&&(e.preventDefault(),e.stopPropagation());else{const t=ge.current;t&&(e.preventDefault(),e.stopPropagation(),g(t,re))}}),[J,ge,re,W,z]),Pe=l((e=>{if("Tab"===e.key)e.preventDefault(),e.stopPropagation(),e.shiftKey&&fe.current?fe.current.focus():me.current&&(oe(e.currentTarget.value),J(!1),me.current.focus());else if("ArrowUp"===e.key&&ge.current&&fe.current){const t=ge.current.querySelector('[role="option"]:not([hidden])');e.currentTarget.id===(null==t?void 0:t.id)&&fe.current&&fe.current.focus()}}),[J,ge]);return u((()=>{const e=e=>{"Escape"===e.key&&z&&J(!1)};return typeof window<"u"&&z&&window.addEventListener("keydown",e),()=>{typeof window<"u"&&window.removeEventListener("keydown",e)}}),[J,z]),e(t,{children:[e("select",{name:w,tabIndex:-1,"data-testid":"jkl-native-select",className:"jkl-sr-only","aria-hidden":!0,ref:ie,value:re,onChange:k,children:[n("option",{value:""})," ",te.map((e=>n("option",{hidden:!e.visible,value:e.value,children:e.label},`${G}-opt-${e.value}`)))]}),n(b,{ref:pe,"data-testid":"jkl-select",className:r("jkl-select",N,{"jkl-select--inline":V,"jkl-select--open":z&&te.some((e=>e.visible)),"jkl-select--no-value":!ae,"jkl-select--invalid":!!C||F}),tooltipProps:M&&{...M,triggerProps:{...M.triggerProps,onFocus:e=>{var t,n;null==(n=null==(t=M.triggerProps)?void 0:t.onFocus)||n.call(t,e),he()}}},...O,id:W?U:q,style:{"--jkl-select-max-shown-options":B,...H},density:I,label:D,labelProps:{id:R,srOnly:V,...E,htmlFor:W?U:q},helpLabel:A,errorLabel:C,render:({"aria-invalid":t,...o})=>e("div",{className:"jkl-select__outer-wrapper",style:{width:K},children:[W&&n("input",{...o,"aria-invalid":t,id:U,hidden:!X,ref:fe,placeholder:"Søk",value:Y,onChange:e=>Z(e.target.value),"data-testid":"jkl-select__search-input",className:"jkl-select__search-input","aria-autocomplete":"list","aria-activedescendant":ae?`${G}__${h(re)}`:void 0,"aria-controls":G,"aria-expanded":z,role:"combobox",onKeyDown:_e,onBlur:ke,onFocus:ye,onClick:e=>{e.stopPropagation()}}),n("button",{"aria-invalid":t,...o,id:q,ref:me,hidden:X,type:"button",name:`${w}-btn`,className:r("jkl-select__button",{"jkl-select__button--active-value":!!re}),"data-testid":"jkl-select__button","aria-label":`${le||"Velg"},${D}`,"aria-expanded":z,"aria-controls":G,onBlur:ke,onFocus:ye,onKeyDown:we,onClick:Q,onMouseDown:e=>{var t;e.preventDefault(),null==(t=me.current)||t.focus()},children:le}),n("div",{id:G,ref:ge,role:"listbox",className:"jkl-select__options-menu",hidden:!z||te.every((e=>!e.visible)),"aria-labelledby":R,tabIndex:-1,"data-focus":"controlled",children:te.map(((t,r)=>t.visible?e("button",{hidden:!t.visible,type:"button",id:`${G}__${h(t.value)}`,className:"jkl-select__option","data-testid":"jkl-select__option","aria-selected":t.value===re,role:"option",value:t.value,"data-testautoid":`jkl-select__option-${r}`,onBlur:ke,onFocus:ye,onKeyDown:Pe,onClick:e=>{e.preventDefault(),ce(t)},onMouseOver:je,children:[t.label,t.description?n("span",{className:"jkl-select__option-description",children:t.description}):null]},`${G}-${t.value}`):null))}),n(m,{variant:"medium",pointingDown:!z,className:"jkl-select__arrow"})]})})]})}));y.displayName="Select";export{y as Select};
|
|
2
2
|
//# sourceMappingURL=Select.js.map
|