@fremtind/jokul 5.2.2 → 5.3.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.
- package/build/build-stats.html +1 -1
- package/build/cjs/components/datepicker/DatePicker.cjs +1 -1
- package/build/cjs/components/datepicker/internal/Calendar.cjs +1 -1
- package/build/cjs/components/datepicker/internal/useCalendar.cjs +1 -1
- package/build/cjs/components/datepicker/internal/utils.cjs +1 -1
- package/build/cjs/components/file/File.cjs +1 -1
- package/build/cjs/components/file/File.cjs.map +1 -1
- package/build/cjs/components/file/types.d.cts +10 -1
- package/build/cjs/components/input-group/FieldGroup.cjs +1 -1
- package/build/cjs/components/input-group/FieldGroup.cjs.map +1 -1
- package/build/cjs/components/input-group/types.d.cts +6 -0
- package/build/cjs/components/tabs/Tabs.cjs.map +1 -1
- package/build/es/components/datepicker/DatePicker.js +1 -1
- package/build/es/components/datepicker/internal/Calendar.js +1 -1
- package/build/es/components/datepicker/internal/useCalendar.js +1 -1
- package/build/es/components/datepicker/internal/utils.js +1 -1
- package/build/es/components/file/File.js +1 -1
- package/build/es/components/file/File.js.map +1 -1
- package/build/es/components/file/types.d.ts +10 -1
- package/build/es/components/input-group/FieldGroup.js +1 -1
- package/build/es/components/input-group/FieldGroup.js.map +1 -1
- package/build/es/components/input-group/types.d.ts +6 -0
- package/build/es/components/tabs/Tabs.js.map +1 -1
- package/build/utils-C5AH4j8B.js +2 -0
- package/build/{utils-DxmZDrR9.cjs.map → utils-C5AH4j8B.js.map} +1 -1
- package/build/utils-CD_aHC6R.cjs +2 -0
- package/build/utils-CD_aHC6R.cjs.map +1 -0
- package/package.json +22 -22
- package/styles/base.css +3 -3
- package/styles/base.min.css +1 -1
- package/styles/components/autosuggest/autosuggest.min.css +1 -1
- package/styles/components/beta/nav-link/navlink.min.css +1 -1
- package/styles/components/beta/select/select.min.css +1 -1
- package/styles/components/button/button.min.css +1 -1
- package/styles/components/card/card.min.css +1 -1
- package/styles/components/checkbox/checkbox.min.css +1 -1
- package/styles/components/checkbox-panel/checkbox-panel.min.css +1 -1
- package/styles/components/combobox/combobox.min.css +1 -1
- package/styles/components/cookie-consent/cookie-consent.min.css +1 -1
- package/styles/components/countdown/countdown.css +2 -2
- package/styles/components/countdown/countdown.min.css +1 -1
- package/styles/components/datepicker/datepicker.min.css +1 -1
- package/styles/components/description-list/description-list.min.css +1 -1
- package/styles/components/expander/accordion.min.css +1 -1
- package/styles/components/expander/expandable.min.css +1 -1
- package/styles/components/feedback/feedback.css +2 -2
- package/styles/components/feedback/feedback.min.css +1 -1
- package/styles/components/file/file.css +50 -61
- package/styles/components/file/file.min.css +1 -1
- package/styles/components/file/file.scss +66 -79
- package/styles/components/file-input/file-input.css +59 -70
- package/styles/components/file-input/file-input.min.css +1 -1
- package/styles/components/icon-button/icon-button.min.css +1 -1
- package/styles/components/input-group/input-group.css +2 -2
- package/styles/components/input-group/input-group.min.css +1 -1
- package/styles/components/input-panel/input-panel.min.css +1 -1
- package/styles/components/link-list/link-list.min.css +1 -1
- package/styles/components/list/list.min.css +1 -1
- package/styles/components/loader/loader.css +6 -6
- package/styles/components/loader/loader.min.css +1 -1
- package/styles/components/loader/skeleton-loader.css +3 -3
- package/styles/components/loader/skeleton-loader.min.css +1 -1
- package/styles/components/menu/menu.min.css +1 -1
- package/styles/components/message/message.css +2 -2
- package/styles/components/message/message.min.css +1 -1
- package/styles/components/modal/modal.min.css +1 -1
- package/styles/components/nav-link/nav-link.min.css +1 -1
- package/styles/components/number-input/number-input.min.css +1 -1
- package/styles/components/popover/popover.min.css +1 -1
- package/styles/components/progress-bar/progress-bar.css +1 -1
- package/styles/components/progress-bar/progress-bar.min.css +1 -1
- package/styles/components/radio-button/radio-button.min.css +1 -1
- package/styles/components/radio-panel/radio-panel.min.css +1 -1
- package/styles/components/search/search-with-submit-button.css +5 -0
- package/styles/components/search/search-with-submit-button.min.css +1 -1
- package/styles/components/search/search-with-submit-button.scss +6 -0
- package/styles/components/search/search.css +8 -0
- package/styles/components/search/search.min.css +1 -1
- package/styles/components/search/search.scss +9 -0
- package/styles/components/segmented-control/segmented-control.css +2 -2
- package/styles/components/segmented-control/segmented-control.min.css +1 -1
- package/styles/components/select/select.min.css +1 -1
- package/styles/components/system-message/system-message.css +2 -2
- package/styles/components/system-message/system-message.min.css +1 -1
- package/styles/components/table/table.min.css +1 -1
- package/styles/components/tabs/tabs.min.css +1 -1
- package/styles/components/text-area/text-area.min.css +1 -1
- package/styles/components/text-input/text-input.min.css +1 -1
- package/styles/components/toast/toast.css +4 -4
- package/styles/components/toast/toast.min.css +1 -1
- package/styles/components/toggle-switch/toggle-switch.min.css +1 -1
- package/styles/components/tooltip/tooltip.min.css +1 -1
- package/styles/components.css +87 -85
- package/styles/components.min.css +1 -1
- package/styles/tailwind.css +12 -0
- package/build/utils-CtwpNW4I.js +0 -2
- package/build/utils-CtwpNW4I.js.map +0 -1
- package/build/utils-DxmZDrR9.cjs +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../clsx-E3yX_9sL.cjs"),r=require("../../../utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../clsx-E3yX_9sL.cjs"),r=require("../../../utils-CD_aHC6R.cjs"),a=require("react"),n=require("react-dom"),o=require("../../utilities/formatters/date/formatDate.cjs"),l=require("../icon-button/IconButton.cjs"),u=require("../icon/icons/CalendarIcon.cjs"),s=require("../input-group/InputGroup.cjs"),i=require("../popover/Popover.cjs"),c=require("../text-input/BaseTextInput.cjs"),d=require("./internal/Calendar.cjs"),p=require("./utils.cjs"),f=require("./validation.cjs"),v=a.forwardRef((v,D)=>{const{"data-testautoid":m,id:b,className:g="",label:j="Velg dato",labelProps:k,defaultValue:h,defaultShow:y=!1,value:x,disableBeforeDate:C,disableAfterDate:S,yearsToShow:L,name:P,helpLabel:q,errorLabel:w,invalid:I,days:O,months:T,monthLabel:B,yearLabel:E,placeholder:_="dd.mm.åååå",width:R="11.25rem",onChange:N,onBlur:U,onFocus:V,onKeyDown:F,action:K,showCalendarLabel:M="Åpne kalender",hideCalendarLabel:W="Lukk kalender",supportLabelProps:A,tooltip:G,textInputProps:H,description:$,...z}=v;"production"!==process.env.NODE_ENV&&x&&h&&console.warn("DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.");const J=p.parseDateString(C),Q=J?r.dayjs(J).startOf("day").toDate():void 0,X=p.parseDateString(S),Y=X?r.dayjs(X).startOf("day").toDate():void 0,[Z,ee]=a.useState(r.getInitialDate(x,h,Q,Y)),[te,re]=a.useState(null),[ae,ne]=a.useState(y),oe=a.useRef(null),le=a.useRef(null),ue=a.useRef(null),se=a.useRef(null),ie=a.useRef(!1),ce=a.useCallback(e=>{se.current=e,D&&("function"==typeof D?D(e):D.current=e)},[D]),de=a.useCallback(e=>{V&&le.current&&(le.current.contains(e.relatedTarget)||V(e,Z,{error:te,value:e.target.value}))},[V,Z,te]),pe=a.useCallback(e=>{U&&U(e,Z,{error:te,value:e.target.value})},[U,Z,te]),fe=a.useCallback(e=>{"Escape"===e.key&&(ne(!1),e.preventDefault(),e.stopPropagation()),K?.onKeyDown&&K.onKeyDown(e)},[K]),ve=a.useCallback(e=>{const t=e.currentTarget.value,r=((e,t)=>{const r=e.replace(/\D/g,""),a=o.formatDateString(r,{partial:!0}),n=e.replace(/\D+$/,""),l=8===r.length?o.formatDateString(r):e,u=p.parseDateString(l)?l:null,s=t&&e!==r&&n===a&&void 0===p.parseDateString(e)&&null===u;return u??(s?r:e)})(t,ie.current);r!==t&&((e,t)=>{const r=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;r?r.call(e,t):e.value=t})(e.currentTarget,r);const a=t.replace(/\D/g,"");ie.current=t===a&&r===o.formatDateString(a)&&r!==t&&void 0!==p.parseDateString(r);const{date:n,error:l}=(({value:e,minDate:t,maxDate:r})=>{if(!e)return{date:null,error:null};const a=p.parseDateString(e);return a?t&&!f.isWithinLowerBound(a,t)?{date:a,error:"OUTSIDE_LOWER_BOUND"}:r&&!f.isWithinUpperBound(a,r)?{date:a,error:"OUTSIDE_UPPER_BOUND"}:{date:a,error:null}:{date:null,error:"WRONG_FORMAT"}})({value:r,minDate:Q,maxDate:Y});n&&!l&&ne(!1),re(l),ee(n),N&&N(e,n,{error:l,value:r})},[N,Q,Y]),De=a.useCallback(e=>{n.flushSync(()=>{ne(!ae)});const t=oe.current,r=t&&t.querySelector('[aria-pressed="true"]');window.requestAnimationFrame(()=>r?.focus()),K?.onClick&&K.onClick(e)},[ae,K]),me=a.useCallback(({date:e})=>{if(ne(!1),ee(e),se.current){const t=se.current;ie.current=!1,t.value=p.formatInput(e);const r=document.createEvent("HTMLEvents");r.initEvent("input",!0,!1),t.dispatchEvent(r),t.focus(),N&&N(r,e,{error:null,value:t.value})}},[N]),be=a.useCallback(e=>{e.preventDefault(),ne(!1),ue.current?.focus()},[]);return e.jsx(s.InputGroup,{id:b,className:t.clsx("jkl-datepicker",g),...z,ref:le,label:j,labelProps:k,helpLabel:q,errorLabel:w,supportLabelProps:A,tooltip:G,description:$,render:t=>e.jsx(c.BaseTextInput,{"data-focused":ae?"true":void 0,ref:ce,"data-testid":"jkl-datepicker__input","data-testautoid":m,className:"jkl-datepicker__input",name:P,defaultValue:h,value:x,type:"text",placeholder:_,width:R,onFocus:de,onBlur:pe,onChange:ve,actionButton:e.jsxs(i.Popover,{positionReference:se,open:ae,onOpenChange:()=>ne(!ae),offset:8,children:[e.jsx(i.Popover.Trigger,{...K,"data-testid":"jkl-datepicker__trigger",className:"jkl-text-input-action-button",title:ae?W:M,tabIndex:0,onClick:De,onKeyDown:fe,asChild:!0,children:e.jsx(l.IconButton,{children:e.jsx(u.CalendarIcon,{})})}),e.jsx(i.Popover.Content,{initialFocus:-1,padding:24,children:e.jsx(d.Calendar,{ref:oe,date:Z,minDate:Q,maxDate:Y,days:O,months:T,monthLabel:B,yearLabel:E,yearsToShow:L,onDateSelected:me,onTabOutside:be})})]}),...H,...t,"aria-invalid":I||!!w})})});v.displayName="DatePicker",exports.DatePicker=v;
|
|
2
2
|
//# sourceMappingURL=DatePicker.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("react-dom"),n=require("../../../hooks/useId/useId.cjs"),r=require("../../button/Button.cjs"),l=require("../../icon/icons/ArrowLeftIcon.cjs"),o=require("../../icon/icons/ArrowRightIcon.cjs"),s=require("../../icon/icons/ChevronDownIcon.cjs"),c=require("./calendarReducer.cjs"),d=require("./useCalendar.cjs"),i=require("../../../../utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("react-dom"),n=require("../../../hooks/useId/useId.cjs"),r=require("../../button/Button.cjs"),l=require("../../icon/icons/ArrowLeftIcon.cjs"),o=require("../../icon/icons/ArrowRightIcon.cjs"),s=require("../../icon/icons/ChevronDownIcon.cjs"),c=require("./calendarReducer.cjs"),d=require("./useCalendar.cjs"),i=require("../../../../utils-CD_aHC6R.cjs"),u=["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],h=["man","tir","ons","tor","fre","lør","søn"],g=t.forwardRef((g,b)=>{const{date:f,defaultSelected:j,minDate:m,maxDate:p,days:k=h,months:v=u,monthLabel:x="Velg måned",yearLabel:D="Velg år",yearsToShow:w=i.DEFAULT_YEARS_TO_SHOW,onTabOutside:y,...S}=g,M=n.useId("jkl-calendar"),[{offset:F,selectedDate:C,shownDate:A},_]=t.useReducer(c.calendarReducer,i.getInitialDateShown(f,j,m,p),c.calendarInitializer),N=A.getMonth(),$=A.getFullYear();t.useEffect(()=>{_({type:"SET_SELECTED_DATE",newDate:i.getInitialDateShown(f,j,m,p)})},[f,j,m,p]);const q=t.useCallback(e=>{_({type:"SET_OFFSET",newOffset:e})},[]),{calendars:E,getBackProps:O,getDateProps:Y,getForwardProps:I,handleOffsetChanged:T}=d.useCalendar({date:C,selected:C,minDate:m,maxDate:p,offset:F,onOffsetChanged:q,firstDayOfWeek:1,...S}),R=t.useRef(null),L=t.useCallback(e=>{if(!R.current)return;const t=document.activeElement,n=R.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]'),r=async e=>{t?.setAttribute("tabindex","-1"),e.setAttribute("tabindex","0"),e.focus()};n.forEach((l,o)=>{const s=o+e;if(l===t)if(s<=n.length-1&&s>=0)r(n[s]);else if(e<0){if(i.isBackDisabled({calendars:E,minDate:m})||(a.flushSync(()=>{T(F-i.subtractMonth({calendars:E,offset:1,minDate:m}))}),!R.current))return;const e=R.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[e.length+s]&&(e[0].setAttribute("tabindex","-1"),r(e[e.length+s]))}else{if(i.isForwardDisabled({calendars:E,maxDate:p})||(a.flushSync(()=>{T(F+i.addMonth({calendars:E,offset:1,maxDate:p}))}),!R.current))return;const e=R.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[s-n.length]&&(e[0].setAttribute("tabindex","-1"),r(e[s-n.length]))}})},[T,F,E,p,m]),B=t.useCallback(e=>{switch(e.key){case"ArrowUp":L(-7),e.preventDefault();break;case"ArrowRight":L(1),e.preventDefault();break;case"ArrowDown":L(7),e.preventDefault();break;case"ArrowLeft":L(-1),e.preventDefault()}},[L]),K=t.useCallback(e=>{if("Tab"!==e.key)return;const t=R.current?.querySelectorAll('button:not([disabled]):not([tabindex="-1"]), select');if(!t)return;const a=t[0],n=t[t.length-1];e.shiftKey||document.activeElement!==n?e.shiftKey&&document.activeElement===a&&(n.focus(),e.preventDefault()):(a.focus(),e.preventDefault())},[]),P=t.useCallback(e=>{const{date:t,selected:a,selectable:n,prevMonth:r,nextMonth:l}=e;return!!n&&!(!a&&t.toString()!==m?.toString()&&(r||l||A.getFullYear()!==t.getFullYear()||C.getMonth()===t.getMonth()||1!==t.getDate()))},[A,m,C]),J=t.useCallback(()=>{m&&A.getFullYear()-m.getFullYear()===0&&A.getMonth()-m.getMonth()===1?document.querySelector(`[data-testid="${M}-forward-button"]`)?.focus():p&&p.getFullYear()-A.getFullYear()===0&&p.getMonth()-A.getMonth()===1&&document.querySelector(`[data-testid="${M}-back-button"]`)?.focus()},[m,p,A,M]),U=t.useCallback(e=>{if(4!==e.target.value.length)return;const t=Number.parseInt(e.target.value);if(Number.isNaN(t))return;let a=12*(t-A.getFullYear());const n=new Date(A.getFullYear(),A.getMonth()+a,A.getDate());p&&p.getFullYear()===n.getFullYear()&&p.getMonth()<n.getMonth()?a-=n.getMonth()-p.getMonth():m&&m.getFullYear()===n.getFullYear()&&m.getMonth()>n.getMonth()&&(a+=m.getMonth()-n.getMonth()),_({type:"ADD_OFFSET",addedOffset:a})},[A,m,p]),V=t.useCallback(e=>{if(!C&&!f)return;const t=A.getFullYear()-(C||new Date).getFullYear(),a=Number.parseInt(e.target.value)-(C||new Date).getMonth();_({type:"SET_OFFSET",newOffset:12*t+a})},[C,f,A]),W=i.getYearSelectOptions($,m,p,w),z=i.getMonthSelectOptions($,v,m,p);return e.jsx("div",{ref:b,id:M,className:"jkl-calendar","data-testid":"jkl-calendar",children:e.jsxs("div",{className:"jkl-calendar__padding",ref:R,onKeyDown:K,children:[e.jsxs("fieldset",{className:"jkl-calendar-navigation",children:[e.jsxs("div",{children:[e.jsx(r.Button,{...O({calendars:E,onClick:J}),"data-testid":`${M}-back-button`,variant:"ghost",icon:e.jsx(l.ArrowLeftIcon,{variant:"medium",bold:!0})}),e.jsx(r.Button,{...I({calendars:E,onClick:J}),variant:"ghost","data-testid":`${M}-forward-button`,icon:e.jsx(o.ArrowRightIcon,{variant:"medium",bold:!0})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"jkl-calendar-navigation-dropdown",children:[e.jsx("select",{onChange:V,className:"jkl-calendar-navigation-dropdown__select","aria-label":x,value:N.toString(),children:z.map(({label:t,value:a})=>e.jsx("option",{value:a,children:t},a))}),e.jsx(s.ChevronDownIcon,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]}),e.jsxs("div",{className:"jkl-calendar-navigation-dropdown",children:[e.jsx("select",{onChange:U,className:"jkl-calendar-navigation-dropdown__select","aria-label":D,value:$.toString(),children:W.map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx(s.ChevronDownIcon,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]})]})]}),E.map(t=>e.jsxs("table",{className:"jkl-calendar-table","data-testid":"jkl-datepicker-calendar",children:[e.jsxs("caption",{className:"jkl-sr-only",children:[v[t.month],", ",t.year]}),e.jsx("thead",{children:e.jsx("tr",{children:k.map(a=>e.jsx("th",{children:a},`${t.month}${t.year}${a}`))})}),e.jsx("tbody",{"data-testid":"jkl-datepicker-dates",children:t.weeks.map((a,n)=>e.jsx("tr",{children:a.map((a,r)=>{const l=`${t.month}${t.year}${n}${r}`;if("string"==typeof a)return e.jsx("td",{className:"jkl-calendar__date jkl-calendar__date--empty",children:a},l);const{date:o,selectable:s,today:c,prevMonth:d,nextMonth:i}=a;return e.jsx("td",{children:e.jsx("button",{...Y({dateObj:a}),type:"button",className:"jkl-calendar-date-button",tabIndex:P(a)?0:-1,"aria-label":`${o.getDate()}. ${v[o.getMonth()].toLowerCase()}`,"aria-current":c?"date":void 0,"data-adjacent":d||i?"true":void 0,disabled:!s,onKeyDown:B,children:e.jsx("span",{"aria-hidden":"true",children:o.getDate()})})},l)})},`${t.month}${t.year}${n}`))})]},`${t.month}${t.year}`))]})})});g.displayName="Calendar",exports.Calendar=g;
|
|
2
2
|
//# sourceMappingURL=Calendar.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../../utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../../utils-CD_aHC6R.cjs"),t=require("react");function a(e){return void 0!==e}function n(t,{onClick:a,dateObj:n}){return{onClick:e.composeEventHandlers(a,e=>{t(n,e)}),disabled:!n.selectable,"aria-pressed":n.selected,role:"button"}}function s({minDate:t,offsetMonth:a,handleOffsetChanged:n},{onClick:s,offset:o=1,calendars:d}){const l=`Gå tilbake ${o} måned${1===o?"":"er"}`;return{onClick:e.composeEventHandlers(s,()=>{n(a-e.subtractMonth({calendars:d,offset:o,minDate:t}))}),disabled:e.isBackDisabled({calendars:d,minDate:t}),"aria-label":l,title:l}}function o({maxDate:t,offsetMonth:a,handleOffsetChanged:n},{onClick:s,offset:o=1,calendars:d}){const l=`Gå frem ${o} måned${1===o?"":"er"}`;return{onClick:e.composeEventHandlers(s,()=>{n(a+e.addMonth({calendars:d,offset:o,maxDate:t}))}),disabled:e.isForwardDisabled({calendars:d,maxDate:t}),"aria-label":l,title:l}}exports.useCalendar=function({date:d=e.dayjs().startOf("day").toDate(),maxDate:l,minDate:r,monthsToDisplay:i=1,firstDayOfWeek:f=0,showOutsideDays:c=!0,offset:u,onDateSelected:D,onOffsetChanged:h,selected:m}){const[b,C]=t.useState(0),O=function(e,t){return a(e)?e:t}(u,b);function g(e){a(u)||C(e),h(e)}return{calendars:e.getCalendars({date:d,selected:m,monthsToDisplay:i,minDate:r,maxDate:l,offset:O,firstDayOfWeek:f,showOutsideDays:c}),getDateProps:n.bind(null,D),getBackProps:s.bind(null,{minDate:r,offsetMonth:O,handleOffsetChanged:g}),getForwardProps:o.bind(null,{maxDate:l,offsetMonth:O,handleOffsetChanged:g}),handleOffsetChanged:g}};
|
|
2
2
|
//# sourceMappingURL=useCalendar.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../../utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../../utils-CD_aHC6R.cjs");require("react"),require("../utils.cjs"),exports.DEFAULT_YEARS_TO_SHOW=e.DEFAULT_YEARS_TO_SHOW,exports.addMonth=e.addMonth,exports.composeEventHandlers=e.composeEventHandlers,exports.dateHasChanged=e.dateHasChanged,exports.dateIsOutsideRange=e.dateIsOutsideRange,exports.getCalendars=e.getCalendars,exports.getInitialDate=e.getInitialDate,exports.getInitialDateShown=e.getInitialDateShown,exports.getMonthSelectOptions=e.getMonthSelectOptions,exports.getYearSelectOptions=e.getYearSelectOptions,exports.isBackDisabled=e.isBackDisabled,exports.isForwardDisabled=e.isForwardDisabled,exports.isSameDay=e.isSameDay,exports.subtractMonth=e.subtractMonth;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../../../clsx-E3yX_9sL.cjs"),c=require("react"),n=require("../../utilities/formatters/bytes/formatBytes.cjs");require("../../utilities/polymorphism/SlotComponent.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../../../clsx-E3yX_9sL.cjs"),c=require("react"),n=require("../../utilities/formatters/bytes/formatBytes.cjs");require("../../utilities/polymorphism/SlotComponent.cjs");const r=require("../button/Button.cjs"),s=require("../file-input/internal/fileInputContext.cjs"),o=require("../flex/Flex.cjs");require("../icon/Icon.cjs"),require("../icon/icons/animated/ArrowVerticalAnimated.cjs"),require("../icon/icons/animated/ArrowHorizontalAnimated.cjs"),require("../icon/icons/animated/PlusRemoveAnimated.cjs"),require("../icon/icons/ArrowDownIcon.cjs"),require("../icon/icons/ArrowLeftIcon.cjs"),require("../icon/icons/ArrowNorthEastIcon.cjs"),require("../icon/icons/ArrowRightIcon.cjs"),require("../icon/icons/ArrowUpIcon.cjs"),require("../icon/icons/CalendarIcon.cjs"),require("../icon/icons/CheckIcon.cjs"),require("../icon/icons/ChevronDownIcon.cjs"),require("../icon/icons/ChevronLeftIcon.cjs"),require("../icon/icons/ChevronRightIcon.cjs"),require("../icon/icons/ChevronUpIcon.cjs"),require("../icon/icons/CloseIcon.cjs"),require("../icon/icons/CopyIcon.cjs"),require("../icon/icons/DotsIcon.cjs"),require("../icon/icons/DragIcon.cjs"),require("../icon/icons/ErrorIcon.cjs"),require("../icon/icons/GreenCheckIcon.cjs"),require("../icon/icons/HamburgerIcon.cjs"),require("../icon/icons/InfoIcon.cjs"),require("../icon/icons/LinkIcon.cjs"),require("../icon/icons/MinusIcon.cjs"),require("../icon/icons/OpenInNewIcon.cjs"),require("../icon/icons/PenIcon.cjs"),require("../icon/icons/PlusIcon.cjs"),require("../icon/icons/QuestionIcon.cjs"),require("../icon/icons/RedCrossIcon.cjs"),require("../icon/icons/SearchIcon.cjs"),require("../icon/icons/SuccessIcon.cjs"),require("../icon/icons/ThumbDownIcon.cjs"),require("../icon/icons/ThumbUpIcon.cjs");const t=require("../icon/icons/TrashCanIcon.cjs");require("../icon/icons/WarningIcon.cjs"),require("../../hooks/useId/useId.cjs");const l=require("../input-group/SupportLabel.cjs");require("../input-group/InputGroup.cjs");const a=require("../link/Link.cjs"),u=require("../typography/Text.cjs");require("../typography/Title.cjs");exports.File=j=>{const{children:q,hideThumbnail:I,className:p,fileName:m,fileType:h,fileSize:d,path:f,file:x,state:k,errorLabel:b="Feil",onRemove:g,variant:_="list",...C}=j,y=`jkl-file-preview-${c.useId()}`,w=`${y}-support`,N=s.useFileInputContext(),v=h.startsWith("image/")&&(x?URL.createObjectURL(x):f),T=e.jsxs("div",{id:y,className:i.clsx(p,"jkl-file",`jkl-file--${_}`),"data-state":k,...C,children:[e.jsxs(o.Flex,{gap:"8",direction:"card"===_?"column":"row",alignItems:"card"===_?"start":"center",className:"jkl-file__content",children:[!I&&e.jsx("div",{className:"jkl-file__thumbnail","data-filetype":h,children:v&&e.jsx("img",{src:v,alt:""})}),e.jsxs(o.Flex,{gap:"8",alignItems:"center",justifyContent:"space-between",className:"jkl-file__info",children:[f?e.jsx(u.Text,{size:"s",className:"jkl-file__name",children:e.jsxs(a.Link,{href:f,children:[m," ",e.jsxs("span",{className:"jkl-file__size",children:["(",n.formatBytes(d),")"]})]})}):e.jsxs(u.Text,{size:"s",className:"jkl-file__name",children:[m," ",e.jsxs("span",{className:"jkl-file__size",children:["(",n.formatBytes(d),")"]})]}),g&&e.jsx(r.Button,{variant:"ghost",className:"jkl-file__button",onClick:g,title:`Fjern ${m}`,icon:e.jsx(t.TrashCanIcon,{})})]})]}),"error"===k&&b&&e.jsx(l.SupportLabel,{className:"jkl-file__support-label",id:w,label:b,labelType:"error"})]});return N?e.jsx("li",{children:T}):T};
|
|
2
2
|
//# sourceMappingURL=File.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.cjs","sources":["../../../../src/components/file/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport
|
|
1
|
+
{"version":3,"file":"File.cjs","sources":["../../../../src/components/file/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentProps, type FC, useId } from \"react\";\nimport { formatBytes } from \"../../utilities/index.js\";\nimport { Button } from \"../button/index.js\";\nimport { useFileInputContext } from \"../file-input/internal/fileInputContext.js\";\nimport { Flex } from \"../flex/index.js\";\nimport { TrashCanIcon } from \"../icon/index.js\";\nimport { SupportLabel } from \"../input-group/index.js\";\nimport { Link } from \"../link/index.js\";\nimport { Text } from \"../typography/index.js\";\nimport type { FileProps } from \"./types.js\";\n\nexport const File: FC<FileProps & ComponentProps<\"div\">> = (props) => {\n const {\n children: _,\n hideThumbnail,\n className,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n state,\n errorLabel = \"Feil\",\n onRemove,\n variant = \"list\",\n ...rest\n } = props;\n\n const id = `jkl-file-preview-${useId()}`;\n const supportId = `${id}-support`;\n\n const context = useFileInputContext();\n\n const imageSrc =\n fileType.startsWith(\"image/\") &&\n (file ? URL.createObjectURL(file) : path);\n\n const fileComponent = (\n <div\n id={id}\n className={clsx(className, \"jkl-file\", `jkl-file--${variant}`)}\n data-state={state}\n {...rest}\n >\n <Flex\n gap=\"8\"\n direction={variant === \"card\" ? \"column\" : \"row\"}\n alignItems={variant === \"card\" ? \"start\" : \"center\"}\n className={\"jkl-file__content\"}\n >\n {!hideThumbnail && (\n <div\n className=\"jkl-file__thumbnail\"\n data-filetype={fileType}\n >\n {imageSrc && <img src={imageSrc} alt=\"\" />}\n </div>\n )}\n <Flex\n gap=\"8\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n className=\"jkl-file__info\"\n >\n {path ? (\n <Text size=\"s\" className=\"jkl-file__name\">\n <Link href={path}>\n {fileName}{\" \"}\n <span className=\"jkl-file__size\">\n ({formatBytes(fileSize)})\n </span>\n </Link>\n </Text>\n ) : (\n <Text size=\"s\" className=\"jkl-file__name\">\n {fileName}{\" \"}\n <span className=\"jkl-file__size\">\n ({formatBytes(fileSize)})\n </span>\n </Text>\n )}\n {onRemove && (\n <Button\n variant={\"ghost\"}\n className=\"jkl-file__button\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n icon={<TrashCanIcon />}\n />\n )}\n </Flex>\n </Flex>\n\n {state === \"error\" && errorLabel && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={errorLabel}\n labelType={\"error\"}\n />\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["props","children","_","hideThumbnail","className","fileName","fileType","fileSize","path","file","state","errorLabel","onRemove","variant","rest","id","useId","supportId","context","useFileInputContext","imageSrc","startsWith","URL","createObjectURL","fileComponent","jsxs","clsx","Flex","gap","direction","alignItems","jsx","src","alt","justifyContent","Text","size","Link","href","formatBytes","Button","onClick","title","icon","TrashCanIcon","SupportLabel","label","labelType"],"mappings":"oqEAY4DA,IACxD,MACIC,SAAUC,EACVC,cAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,MAAAA,EACAC,WAAAA,EAAa,OACbC,SAAAA,EACAC,QAAAA,EAAU,UACPC,GACHd,EAEEe,EAAK,oBAAoBC,EAAAA,UACzBC,EAAY,GAAGF,YAEfG,EAAUC,EAAAA,sBAEVC,EACFd,EAASe,WAAW,YACnBZ,EAAOa,IAAIC,gBAAgBd,GAAQD,GAElCgB,EACFC,EAAAA,KAAC,MAAA,CACGV,GAAAA,EACAX,UAAWsB,EAAAA,KAAKtB,EAAW,WAAY,aAAaS,KACpD,aAAYH,KACRI,EAEJb,SAAA,CAAAwB,EAAAA,KAACE,EAAAA,KAAA,CACGC,IAAI,IACJC,UAAuB,SAAZhB,EAAqB,SAAW,MAC3CiB,WAAwB,SAAZjB,EAAqB,QAAU,SAC3CT,UAAW,oBAEVH,SAAA,EAACE,GACE4B,EAAAA,IAAC,MAAA,CACG3B,UAAU,sBACV,gBAAeE,EAEdL,YAAY8B,EAAAA,IAAC,MAAA,CAAIC,IAAKZ,EAAUa,IAAI,OAG7CR,EAAAA,KAACE,EAAAA,KAAA,CACGC,IAAI,IACJE,WAAW,SACXI,eAAe,gBACf9B,UAAU,iBAETH,SAAA,CAAAO,EACGuB,EAAAA,IAACI,EAAAA,MAAKC,KAAK,IAAIhC,UAAU,iBACrBH,SAAAwB,EAAAA,KAACY,EAAAA,KAAA,CAAKC,KAAM9B,EACPP,SAAA,CAAAI,EAAU,IACXoB,EAAAA,KAAC,OAAA,CAAKrB,UAAU,iBAAiBH,SAAA,CAAA,IAC3BsC,EAAAA,YAAYhC,GAAU,YAKpCkB,EAAAA,KAACU,EAAAA,MAAKC,KAAK,IAAIhC,UAAU,iBACpBH,SAAA,CAAAI,EAAU,IACXoB,EAAAA,KAAC,OAAA,CAAKrB,UAAU,iBAAiBH,SAAA,CAAA,IAC3BsC,EAAAA,YAAYhC,GAAU,UAInCK,GACGmB,EAAAA,IAACS,EAAAA,OAAA,CACG3B,QAAS,QACTT,UAAU,mBACVqC,QAAS7B,EACT8B,MAAO,SAASrC,IAChBsC,WAAOC,EAAAA,aAAA,CAAA,WAMZ,UAAVlC,GAAqBC,GAClBoB,EAAAA,IAACc,EAAAA,aAAA,CACGzC,UAAU,0BACVW,GAAIE,EACJ6B,MAAOnC,EACPoC,UAAW,aAM3B,OAAO7B,EAAUa,EAAAA,IAAC,KAAA,CAAI9B,SAAAuB,IAAsBA"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { MouseEvent } from 'react';
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
export type FileProps = {
|
|
3
3
|
fileName: string;
|
|
4
4
|
fileType: string;
|
|
5
5
|
fileSize: number;
|
|
6
6
|
path?: string;
|
|
7
7
|
errorLabel?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Du kan skjule forhåndsvisning av bilde/filendelse for å spare plass
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
hideThumbnail?: boolean;
|
|
8
13
|
state?: "error" | "loading";
|
|
9
14
|
/**
|
|
10
15
|
* Velg hvordan filene skal vises for brukeren
|
|
@@ -17,4 +22,8 @@ export type FileProps = {
|
|
|
17
22
|
* Gjør det mulig å vise en knapp for fjerning av filene ved filopplasting
|
|
18
23
|
*/
|
|
19
24
|
onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Blir ikke brukt, vil fjernes i neste major-release
|
|
27
|
+
*/
|
|
28
|
+
children?: ReactNode;
|
|
20
29
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("../../../clsx-E3yX_9sL.cjs");require("react");const l=require("../../hooks/useId/useId.cjs"),s=require("./Label.cjs"),i=require("./SupportLabel.cjs");exports.FieldGroup=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("../../../clsx-E3yX_9sL.cjs");require("react");const l=require("../../hooks/useId/useId.cjs"),s=require("./Label.cjs"),i=require("./SupportLabel.cjs");exports.FieldGroup=o=>{const{id:t,legend:a,labelProps:d,supportLabelProps:c,tooltip:p,className:n,children:u,helpLabel:j,errorLabel:b,description:x,"data-testautoid":g,...h}=o,f=l.useId(t||"jkl-field-group",{generateSuffix:!t}),m=`${f}_support-label`,L=`${f}_description`,q=b||j,S=b?"error":j?"help":void 0,k=[x?L:void 0,q?m:void 0].filter(Boolean).join(" ")||void 0;return e.jsxs("fieldset",{id:f,className:r.clsx("jkl-field-group",n),"data-testautoid":g,...h,"aria-describedby":k,children:[e.jsx("legend",{className:"jkl-field-group__legend",children:e.jsx(s.Label,{...d,children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{whiteSpace:"normal"},children:a})," ",p]}):a})}),x&&e.jsx("p",{className:"jkl-input-group-description",id:L,children:x}),u,(j||b)&&e.jsx(i.SupportLabel,{...c,label:q,labelType:S,id:m})]})};
|
|
2
2
|
//# sourceMappingURL=FieldGroup.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroup.cjs","sources":["../../../../src/components/input-group/FieldGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label } from \"./Label.js\";\nimport { SupportLabel } from \"./SupportLabel.js\";\nimport type { FieldGroupProps } from \"./types.js\";\n\nexport const FieldGroup: FC<FieldGroupProps> = (props) => {\n const {\n id,\n legend,\n labelProps,\n supportLabelProps,\n tooltip,\n className,\n children,\n helpLabel,\n errorLabel,\n description,\n \"data-testautoid\": testAutoId,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-field-group\", { generateSuffix: !id });\n const supportId = `${uid}_support-label`;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy
|
|
1
|
+
{"version":3,"file":"FieldGroup.cjs","sources":["../../../../src/components/input-group/FieldGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label } from \"./Label.js\";\nimport { SupportLabel } from \"./SupportLabel.js\";\nimport type { FieldGroupProps } from \"./types.js\";\n\nexport const FieldGroup: FC<FieldGroupProps> = (props) => {\n const {\n id,\n legend,\n labelProps,\n supportLabelProps,\n tooltip,\n className,\n children,\n helpLabel,\n errorLabel,\n description,\n \"data-testautoid\": testAutoId,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-field-group\", { generateSuffix: !id });\n const supportId = `${uid}_support-label`;\n const descriptionId = `${uid}_description`;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy =\n [\n description ? descriptionId : undefined,\n supportText ? supportId : undefined,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n return (\n <fieldset\n id={uid}\n className={clsx(\"jkl-field-group\", className)}\n data-testautoid={testAutoId}\n {...rest}\n aria-describedby={describedBy}\n >\n <legend className=\"jkl-field-group__legend\">\n <Label {...labelProps}>\n {tooltip ? (\n <>\n <span style={{ whiteSpace: \"normal\" }}>\n {legend}\n </span>\n {\"\\u00A0\"}\n {tooltip}\n </>\n ) : (\n legend\n )}\n </Label>\n </legend>\n {description && (\n <p className=\"jkl-input-group-description\" id={descriptionId}>\n {description}\n </p>\n )}\n {children}\n {(helpLabel || errorLabel) && (\n <SupportLabel\n {...supportLabelProps}\n label={supportText}\n labelType={supportTextType}\n id={supportId}\n />\n )}\n </fieldset>\n );\n};\n"],"names":["props","id","legend","labelProps","supportLabelProps","tooltip","className","children","helpLabel","errorLabel","description","testAutoId","rest","uid","useId","generateSuffix","supportId","descriptionId","supportText","supportTextType","describedBy","filter","Boolean","join","jsxs","clsx","jsx","Label","Fragment","style","whiteSpace","SupportLabel","label","labelType"],"mappings":"ySAOgDA,IAC5C,MACIC,GAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,YAAAA,EACA,kBAAmBC,KAChBC,GACHZ,EAEEa,EAAMC,EAAAA,MAAMb,GAAM,kBAAmB,CAAEc,gBAAiBd,IACxDe,EAAY,GAAGH,kBACfI,EAAgB,GAAGJ,gBAEnBK,EAAcT,GAAcD,EAC5BW,EAAkBV,EAClB,QACAD,EACE,YACA,EAEFY,EACF,CACIV,EAAcO,OAAgB,EAC9BC,EAAcF,OAAY,GAEzBK,OAAOC,SACPC,KAAK,WAAQ,EAEtB,OACIC,EAAAA,KAAC,WAAA,CACGvB,GAAIY,EACJP,UAAWmB,EAAAA,KAAK,kBAAmBnB,GACnC,kBAAiBK,KACbC,EACJ,mBAAkBQ,EAElBb,SAAA,CAAAmB,EAAAA,IAAC,SAAA,CAAOpB,UAAU,0BACdC,SAAAmB,EAAAA,IAACC,EAAAA,UAAUxB,EACNI,WACGiB,EAAAA,KAAAI,EAAAA,SAAA,CACIrB,SAAA,CAAAmB,MAAC,QAAKG,MAAO,CAAEC,WAAY,UACtBvB,SAAAL,IAEJ,IACAG,KAGLH,MAIXQ,GACGgB,EAAAA,IAAC,IAAA,CAAEpB,UAAU,8BAA8BL,GAAIgB,EAC1CV,SAAAG,IAGRH,GACCC,GAAaC,IACXiB,EAAAA,IAACK,EAAAA,aAAA,IACO3B,EACJ4B,MAAOd,EACPe,UAAWd,EACXlB,GAAIe"}
|
|
@@ -6,6 +6,9 @@ export interface FieldGroupProps extends DataTestAutoId, FieldsetHTMLAttributes<
|
|
|
6
6
|
supportLabelProps?: Omit<SupportLabelProps, "id" | "errorLabel" | "helpLabel">;
|
|
7
7
|
tooltip?: ReactNode;
|
|
8
8
|
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Bruk heller `description`.
|
|
11
|
+
*/
|
|
9
12
|
helpLabel?: string;
|
|
10
13
|
errorLabel?: string;
|
|
11
14
|
description?: string;
|
|
@@ -21,6 +24,9 @@ export type InputGroupProps = WithOptionalChildren & DataTestAutoId & {
|
|
|
21
24
|
"data-testid"?: string;
|
|
22
25
|
"data-size"?: Size;
|
|
23
26
|
errorLabel?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Bruk heller `description`.
|
|
29
|
+
*/
|
|
24
30
|
helpLabel?: ReactNode;
|
|
25
31
|
inline?: boolean;
|
|
26
32
|
label: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.cjs","sources":["../../../../../../node_modules/.pnpm/nanoid@5.1.
|
|
1
|
+
{"version":3,"file":"Tabs.cjs","sources":["../../../../../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/url-alphabet/index.js","../../../../../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/index.browser.js","../../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["export let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","\n\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet } from './url-alphabet/index.js'\n\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let j = size\n while (j--) {\n id += alphabet[bytes[j] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n if (bytes[j] < safeByteCutoff) {\n id += alphabet[bytes[j] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\n\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\n\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import clsx from \"clsx\";\nimport { nanoid } from \"nanoid\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { usePreviousValue } from \"../../hooks/usePreviousValue/usePreviousValue.js\";\nimport type { InjectedProps } from \"./TabList.js\";\nimport type { TabListProps, TabPanelProps, TabsProps } from \"./types.js\";\n\n/**\n * Konteiner for et grensesnitt hvor man kan tabbe mellom innhold.\n * Må inneholde en TabList etterfulgt av en eller flere TabPanel.\n *\n * Docs: https://jokul.fremtind.no/komponenter/tabs\n */\nexport const Tabs = ({ onChange, defaultTab, ...props }: TabsProps) => {\n const [activeIndex, setActiveIndex] = useState(defaultTab ?? 0);\n\n const previousTabIndex = usePreviousValue(activeIndex);\n\n useEffect(() => {\n if (\n previousTabIndex !== undefined &&\n previousTabIndex !== activeIndex &&\n onChange\n ) {\n onChange(activeIndex);\n }\n }, [onChange, previousTabIndex, activeIndex]);\n\n const [tabIDs, setTabIDs] = useState<string[]>([]);\n const [tabPanelIDs, setTabPanelIds] = useState<string[]>([]);\n\n const resolveIDs = useCallback(() => {\n const tabList = React.Children.toArray(props.children)[0];\n\n if (!React.isValidElement(tabList)) return;\n\n React.Children.forEach(tabList.props.children, (tab) => {\n if (!React.isValidElement(tab)) return;\n\n setTabIDs((prev) => [...prev, `jkl-tab-${nanoid(8)}`]);\n setTabPanelIds((prev) => [...prev, `jkl-tabpanel-${nanoid(8)}`]);\n });\n }, [props.children]);\n\n const renderTabList = () => {\n const tabList = React.Children.toArray(props.children)[0];\n\n if (!React.isValidElement<TabListProps & InjectedProps>(tabList))\n return;\n\n return React.cloneElement<TabListProps & InjectedProps>(tabList, {\n activeIndex,\n setActiveIndex,\n tabIDs,\n tabPanelIDs,\n });\n };\n\n const renderTabPanels = () => {\n return React.Children.map(props.children, (child, childIndex) => {\n if (\n !React.isValidElement<\n TabPanelProps & React.HTMLAttributes<HTMLDivElement>\n >(child) ||\n childIndex === 0\n )\n return;\n\n const tabPanelIndex = childIndex - 1;\n\n return tabPanelIndex === activeIndex\n ? React.cloneElement<\n TabPanelProps & React.HTMLAttributes<HTMLDivElement>\n >(child, {\n \"aria-labelledby\": tabIDs[tabPanelIndex],\n id: tabPanelIDs[tabPanelIndex],\n })\n : null;\n });\n };\n\n useEffect(() => {\n resolveIDs();\n }, [resolveIDs]);\n\n return (\n <div {...props} className={clsx(\"jkl-tabs\", props.className)}>\n {renderTabList()}\n {renderTabPanels()}\n </div>\n );\n};\n"],"names":["nanoid","size","id","bytes","crypto","getRandomValues","Uint8Array","onChange","defaultTab","props","activeIndex","setActiveIndex","useState","previousTabIndex","usePreviousValue","useEffect","tabIDs","setTabIDs","tabPanelIDs","setTabPanelIds","resolveIDs","useCallback","tabList","React","Children","toArray","children","isValidElement","forEach","tab","prev","jsxs","className","clsx","cloneElement","renderTabList","map","child","childIndex","tabPanelIndex"],"mappings":"+OAAO,ICiDIA,EAAS,CAACC,EAAO,MAC1B,IAAIC,EAAK,GACLC,EAAQC,OAAOC,gBAAgB,IAAIC,WAAYL,GAAQ,IAC3D,KAAOA,KACLC,GDpDF,mECoDwC,GAAdC,EAAMF,IAEhC,OAAOC,gBC1CW,EAAGK,SAAAA,EAAUC,WAAAA,KAAeC,MAC5C,MAAOC,EAAaC,GAAkBC,EAAAA,SAASJ,GAAc,GAEvDK,EAAmBC,EAAAA,iBAAiBJ,GAE1CK,EAAAA,UAAU,UAEmB,IAArBF,GACAA,IAAqBH,GACrBH,GAEAA,EAASG,IAEd,CAACH,EAAUM,EAAkBH,IAEhC,MAAOM,EAAQC,GAAaL,EAAAA,SAAmB,KACxCM,EAAaC,GAAkBP,EAAAA,SAAmB,IAEnDQ,EAAaC,EAAAA,YAAY,KAC3B,MAAMC,EAAUC,EAAMC,SAASC,QAAQhB,EAAMiB,UAAU,GAElDH,EAAMI,eAAeL,IAE1BC,EAAMC,SAASI,QAAQN,EAAQb,MAAMiB,SAAWG,IACvCN,EAAMI,eAAeE,KAE1BZ,EAAWa,GAAS,IAAIA,EAAM,WAAW9B,EAAO,OAChDmB,EAAgBW,GAAS,IAAIA,EAAM,gBAAgB9B,EAAO,WAE/D,CAACS,EAAMiB,WAuCVX,OAAAA,EAAAA,UAAU,KACNK,KACD,CAACA,IAGAW,OAAC,UAAQtB,EAAOuB,UAAWC,EAAAA,KAAK,WAAYxB,EAAMuB,WAC7CN,SAAA,CA3Ca,MAClB,MAAMJ,EAAUC,EAAMC,SAASC,QAAQhB,EAAMiB,UAAU,GAEvD,GAAKH,EAAMI,eAA6CL,GAGxD,OAAOC,EAAMW,aAA2CZ,EAAS,CAC7DZ,YAAAA,EACAC,eAAAA,EACAK,OAAAA,EACAE,YAAAA,KAiCCiB,GA5BEZ,EAAMC,SAASY,IAAI3B,EAAMiB,SAAU,CAACW,EAAOC,KAC9C,IACKf,EAAMI,eAELU,IACa,IAAfC,EAEA,OAEJ,MAAMC,EAAgBD,EAAa,EAEnC,OAAOC,IAAkB7B,EACnBa,EAAMW,aAEJG,EAAO,CACL,kBAAmBrB,EAAOuB,GAC1BrC,GAAIgB,EAAYqB,KAEpB","x_google_ignoreList":[0,1]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{c as r}from"../../../clsx-BeLtu-UY.js";import{d as a,g as o}from"../../../utils-
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{c as r}from"../../../clsx-BeLtu-UY.js";import{d as a,g as o}from"../../../utils-C5AH4j8B.js";import{forwardRef as n,useState as l,useRef as s,useCallback as i}from"react";import{flushSync as u}from"react-dom";import{formatDateString as c}from"../../utilities/formatters/date/formatDate.js";import{IconButton as d}from"../icon-button/IconButton.js";import{CalendarIcon as p}from"../icon/icons/CalendarIcon.js";import{InputGroup as m}from"../input-group/InputGroup.js";import{Popover as f}from"../popover/Popover.js";import{BaseTextInput as v}from"../text-input/BaseTextInput.js";import{Calendar as D}from"./internal/Calendar.js";import{parseDateString as h,formatInput as b}from"./utils.js";import{isWithinLowerBound as g,isWithinUpperBound as k}from"./validation.js";const j=n((n,j)=>{const{"data-testautoid":y,id:L,className:w="",label:x="Velg dato",labelProps:C,defaultValue:I,defaultShow:O=!1,value:P,disableBeforeDate:T,disableAfterDate:B,yearsToShow:E,name:_,helpLabel:S,errorLabel:N,invalid:R,days:U,months:V,monthLabel:F,yearLabel:K,placeholder:W="dd.mm.åååå",width:A="11.25rem",onChange:G,onBlur:H,onFocus:M,onKeyDown:q,action:$,showCalendarLabel:z="Åpne kalender",hideCalendarLabel:J="Lukk kalender",supportLabelProps:Q,tooltip:X,textInputProps:Y,description:Z,...ee}=n;"production"!==process.env.NODE_ENV&&P&&I&&console.warn("DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.");const te=h(T),re=te?a(te).startOf("day").toDate():void 0,ae=h(B),oe=ae?a(ae).startOf("day").toDate():void 0,[ne,le]=l(o(P,I,re,oe)),[se,ie]=l(null),[ue,ce]=l(O),de=s(null),pe=s(null),me=s(null),fe=s(null),ve=s(!1),De=i(e=>{fe.current=e,j&&("function"==typeof j?j(e):j.current=e)},[j]),he=i(e=>{M&&pe.current&&(pe.current.contains(e.relatedTarget)||M(e,ne,{error:se,value:e.target.value}))},[M,ne,se]),be=i(e=>{H&&H(e,ne,{error:se,value:e.target.value})},[H,ne,se]),ge=i(e=>{"Escape"===e.key&&(ce(!1),e.preventDefault(),e.stopPropagation()),$?.onKeyDown&&$.onKeyDown(e)},[$]),ke=i(e=>{const t=e.currentTarget.value,r=((e,t)=>{const r=e.replace(/\D/g,""),a=c(r,{partial:!0}),o=e.replace(/\D+$/,""),n=8===r.length?c(r):e,l=h(n)?n:null,s=t&&e!==r&&o===a&&void 0===h(e)&&null===l;return l??(s?r:e)})(t,ve.current);r!==t&&((e,t)=>{const r=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;r?r.call(e,t):e.value=t})(e.currentTarget,r);const a=t.replace(/\D/g,"");ve.current=t===a&&r===c(a)&&r!==t&&void 0!==h(r);const{date:o,error:n}=(({value:e,minDate:t,maxDate:r})=>{if(!e)return{date:null,error:null};const a=h(e);return a?t&&!g(a,t)?{date:a,error:"OUTSIDE_LOWER_BOUND"}:r&&!k(a,r)?{date:a,error:"OUTSIDE_UPPER_BOUND"}:{date:a,error:null}:{date:null,error:"WRONG_FORMAT"}})({value:r,minDate:re,maxDate:oe});o&&!n&&ce(!1),ie(n),le(o),G&&G(e,o,{error:n,value:r})},[G,re,oe]),je=i(e=>{u(()=>{ce(!ue)});const t=de.current,r=t&&t.querySelector('[aria-pressed="true"]');window.requestAnimationFrame(()=>r?.focus()),$?.onClick&&$.onClick(e)},[ue,$]),ye=i(({date:e})=>{if(ce(!1),le(e),fe.current){const t=fe.current;ve.current=!1,t.value=b(e);const r=document.createEvent("HTMLEvents");r.initEvent("input",!0,!1),t.dispatchEvent(r),t.focus(),G&&G(r,e,{error:null,value:t.value})}},[G]),Le=i(e=>{e.preventDefault(),ce(!1),me.current?.focus()},[]);return e(m,{id:L,className:r("jkl-datepicker",w),...ee,ref:pe,label:x,labelProps:C,helpLabel:S,errorLabel:N,supportLabelProps:Q,tooltip:X,description:Z,render:r=>e(v,{"data-focused":ue?"true":void 0,ref:De,"data-testid":"jkl-datepicker__input","data-testautoid":y,className:"jkl-datepicker__input",name:_,defaultValue:I,value:P,type:"text",placeholder:W,width:A,onFocus:he,onBlur:be,onChange:ke,actionButton:t(f,{positionReference:fe,open:ue,onOpenChange:()=>ce(!ue),offset:8,children:[e(f.Trigger,{...$,"data-testid":"jkl-datepicker__trigger",className:"jkl-text-input-action-button",title:ue?J:z,tabIndex:0,onClick:je,onKeyDown:ge,asChild:!0,children:e(d,{children:e(p,{})})}),e(f.Content,{initialFocus:-1,padding:24,children:e(D,{ref:de,date:ne,minDate:re,maxDate:oe,days:U,months:V,monthLabel:F,yearLabel:K,yearsToShow:E,onDateSelected:ye,onTabOutside:Le})})]}),...Y,...r,"aria-invalid":R||!!N})})});j.displayName="DatePicker";export{j as DatePicker};
|
|
2
2
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{forwardRef as a,useReducer as n,useEffect as r,useCallback as l,useRef as o}from"react";import{flushSync as s}from"react-dom";import{useId as d}from"../../../hooks/useId/useId.js";import{Button as c}from"../../button/Button.js";import{ArrowLeftIcon as i}from"../../icon/icons/ArrowLeftIcon.js";import{ArrowRightIcon as u}from"../../icon/icons/ArrowRightIcon.js";import{ChevronDownIcon as h}from"../../icon/icons/ChevronDownIcon.js";import{calendarReducer as m,calendarInitializer as f}from"./calendarReducer.js";import{useCalendar as g}from"./useCalendar.js";import{D as b,a as p,i as v,s as k,b as j,c as D,e as w,f as y}from"../../../../utils-
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{forwardRef as a,useReducer as n,useEffect as r,useCallback as l,useRef as o}from"react";import{flushSync as s}from"react-dom";import{useId as d}from"../../../hooks/useId/useId.js";import{Button as c}from"../../button/Button.js";import{ArrowLeftIcon as i}from"../../icon/icons/ArrowLeftIcon.js";import{ArrowRightIcon as u}from"../../icon/icons/ArrowRightIcon.js";import{ChevronDownIcon as h}from"../../icon/icons/ChevronDownIcon.js";import{calendarReducer as m,calendarInitializer as f}from"./calendarReducer.js";import{useCalendar as g}from"./useCalendar.js";import{D as b,a as p,i as v,s as k,b as j,c as D,e as w,f as y}from"../../../../utils-C5AH4j8B.js";const M=["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],F=["man","tir","ons","tor","fre","lør","søn"],S=a((a,S)=>{const{date:A,defaultSelected:N,minDate:_,maxDate:$,days:x=F,months:C=M,monthLabel:E="Velg måned",yearLabel:Y="Velg år",yearsToShow:I=b,onTabOutside:O,...T}=a,R=d("jkl-calendar"),[{offset:L,selectedDate:q,shownDate:K},B]=n(m,p(A,N,_,$),f),J=K.getMonth(),P=K.getFullYear();r(()=>{B({type:"SET_SELECTED_DATE",newDate:p(A,N,_,$)})},[A,N,_,$]);const V=l(e=>{B({type:"SET_OFFSET",newOffset:e})},[]),{calendars:z,getBackProps:U,getDateProps:W,getForwardProps:G,handleOffsetChanged:H}=g({date:q,selected:q,minDate:_,maxDate:$,offset:L,onOffsetChanged:V,firstDayOfWeek:1,...T}),Q=o(null),X=l(e=>{if(!Q.current)return;const t=document.activeElement,a=Q.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]'),n=async e=>{t?.setAttribute("tabindex","-1"),e.setAttribute("tabindex","0"),e.focus()};a.forEach((r,l)=>{const o=l+e;if(r===t)if(o<=a.length-1&&o>=0)n(a[o]);else if(e<0){if(v({calendars:z,minDate:_})||(s(()=>{H(L-k({calendars:z,offset:1,minDate:_}))}),!Q.current))return;const e=Q.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[e.length+o]&&(e[0].setAttribute("tabindex","-1"),n(e[e.length+o]))}else{if(j({calendars:z,maxDate:$})||(s(()=>{H(L+D({calendars:z,offset:1,maxDate:$}))}),!Q.current))return;const e=Q.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[o-a.length]&&(e[0].setAttribute("tabindex","-1"),n(e[o-a.length]))}})},[H,L,z,$,_]),Z=l(e=>{switch(e.key){case"ArrowUp":X(-7),e.preventDefault();break;case"ArrowRight":X(1),e.preventDefault();break;case"ArrowDown":X(7),e.preventDefault();break;case"ArrowLeft":X(-1),e.preventDefault()}},[X]),ee=l(e=>{if("Tab"!==e.key)return;const t=Q.current?.querySelectorAll('button:not([disabled]):not([tabindex="-1"]), select');if(!t)return;const a=t[0],n=t[t.length-1];e.shiftKey||document.activeElement!==n?e.shiftKey&&document.activeElement===a&&(n.focus(),e.preventDefault()):(a.focus(),e.preventDefault())},[]),te=l(e=>{const{date:t,selected:a,selectable:n,prevMonth:r,nextMonth:l}=e;return!!n&&!(!a&&t.toString()!==_?.toString()&&(r||l||K.getFullYear()!==t.getFullYear()||q.getMonth()===t.getMonth()||1!==t.getDate()))},[K,_,q]),ae=l(()=>{_&&K.getFullYear()-_.getFullYear()===0&&K.getMonth()-_.getMonth()===1?document.querySelector(`[data-testid="${R}-forward-button"]`)?.focus():$&&$.getFullYear()-K.getFullYear()===0&&$.getMonth()-K.getMonth()===1&&document.querySelector(`[data-testid="${R}-back-button"]`)?.focus()},[_,$,K,R]),ne=l(e=>{if(4!==e.target.value.length)return;const t=Number.parseInt(e.target.value);if(Number.isNaN(t))return;let a=12*(t-K.getFullYear());const n=new Date(K.getFullYear(),K.getMonth()+a,K.getDate());$&&$.getFullYear()===n.getFullYear()&&$.getMonth()<n.getMonth()?a-=n.getMonth()-$.getMonth():_&&_.getFullYear()===n.getFullYear()&&_.getMonth()>n.getMonth()&&(a+=_.getMonth()-n.getMonth()),B({type:"ADD_OFFSET",addedOffset:a})},[K,_,$]),re=l(e=>{if(!q&&!A)return;const t=K.getFullYear()-(q||new Date).getFullYear(),a=Number.parseInt(e.target.value)-(q||new Date).getMonth();B({type:"SET_OFFSET",newOffset:12*t+a})},[q,A,K]),le=w(P,_,$,I),oe=y(P,C,_,$);return e("div",{ref:S,id:R,className:"jkl-calendar","data-testid":"jkl-calendar",children:t("div",{className:"jkl-calendar__padding",ref:Q,onKeyDown:ee,children:[t("fieldset",{className:"jkl-calendar-navigation",children:[t("div",{children:[e(c,{...U({calendars:z,onClick:ae}),"data-testid":`${R}-back-button`,variant:"ghost",icon:e(i,{variant:"medium",bold:!0})}),e(c,{...G({calendars:z,onClick:ae}),variant:"ghost","data-testid":`${R}-forward-button`,icon:e(u,{variant:"medium",bold:!0})})]}),t("div",{children:[t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:re,className:"jkl-calendar-navigation-dropdown__select","aria-label":E,value:J.toString(),children:oe.map(({label:t,value:a})=>e("option",{value:a,children:t},a))}),e(h,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]}),t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:ne,className:"jkl-calendar-navigation-dropdown__select","aria-label":Y,value:P.toString(),children:le.map(t=>e("option",{value:t,children:t},t))}),e(h,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]})]})]}),z.map(a=>t("table",{className:"jkl-calendar-table","data-testid":"jkl-datepicker-calendar",children:[t("caption",{className:"jkl-sr-only",children:[C[a.month],", ",a.year]}),e("thead",{children:e("tr",{children:x.map(t=>e("th",{children:t},`${a.month}${a.year}${t}`))})}),e("tbody",{"data-testid":"jkl-datepicker-dates",children:a.weeks.map((t,n)=>e("tr",{children:t.map((t,r)=>{const l=`${a.month}${a.year}${n}${r}`;if("string"==typeof t)return e("td",{className:"jkl-calendar__date jkl-calendar__date--empty",children:t},l);const{date:o,selectable:s,today:d,prevMonth:c,nextMonth:i}=t;return e("td",{children:e("button",{...W({dateObj:t}),type:"button",className:"jkl-calendar-date-button",tabIndex:te(t)?0:-1,"aria-label":`${o.getDate()}. ${C[o.getMonth()].toLowerCase()}`,"aria-current":d?"date":void 0,"data-adjacent":c||i?"true":void 0,disabled:!s,onKeyDown:Z,children:e("span",{"aria-hidden":"true",children:o.getDate()})})},l)})},`${a.month}${a.year}${n}`))})]},`${a.month}${a.year}`))]})})});S.displayName="Calendar";export{S as Calendar};
|
|
2
2
|
//# sourceMappingURL=Calendar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as e,d as a,b as t,j as n,i as s,s as o,c as f}from"../../../../utils-
|
|
1
|
+
import{h as e,d as a,b as t,j as n,i as s,s as o,c as f}from"../../../../utils-C5AH4j8B.js";import{useState as l}from"react";function d(e){return void 0!==e}function i(e,{onClick:a,dateObj:t}){return{onClick:n(a,a=>{e(t,a)}),disabled:!t.selectable,"aria-pressed":t.selected,role:"button"}}function r({minDate:e,offsetMonth:a,handleOffsetChanged:t},{onClick:f,offset:l=1,calendars:d}){const i=`Gå tilbake ${l} måned${1===l?"":"er"}`;return{onClick:n(f,()=>{t(a-o({calendars:d,offset:l,minDate:e}))}),disabled:s({calendars:d,minDate:e}),"aria-label":i,title:i}}function c({maxDate:e,offsetMonth:a,handleOffsetChanged:s},{onClick:o,offset:l=1,calendars:d}){const i=`Gå frem ${l} måned${1===l?"":"er"}`;return{onClick:n(o,()=>{s(a+f({calendars:d,offset:l,maxDate:e}))}),disabled:t({calendars:d,maxDate:e}),"aria-label":i,title:i}}function u({date:t=a().startOf("day").toDate(),maxDate:n,minDate:s,monthsToDisplay:o=1,firstDayOfWeek:f=0,showOutsideDays:u=!0,offset:m,onDateSelected:D,onOffsetChanged:h,selected:b}){const[C,O]=l(0),k=function(e,a){return d(e)?e:a}(m,C);function g(e){d(m)||O(e),h(e)}return{calendars:e({date:t,selected:b,monthsToDisplay:o,minDate:s,maxDate:n,offset:k,firstDayOfWeek:f,showOutsideDays:u}),getDateProps:i.bind(null,D),getBackProps:r.bind(null,{minDate:s,offsetMonth:k,handleOffsetChanged:g}),getForwardProps:c.bind(null,{maxDate:n,offsetMonth:k,handleOffsetChanged:g}),handleOffsetChanged:g}}export{u as useCalendar};
|
|
2
2
|
//# sourceMappingURL=useCalendar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as a,c as s,j as t,k as e,l as i,h as o,g as n,a as r,f as d,e as l,i as c,b as g,m,s as p}from"../../../../utils-
|
|
1
|
+
import{D as a,c as s,j as t,k as e,l as i,h as o,g as n,a as r,f as d,e as l,i as c,b as g,m,s as p}from"../../../../utils-C5AH4j8B.js";import"react";import"../utils.js";export{a as DEFAULT_YEARS_TO_SHOW,s as addMonth,t as composeEventHandlers,e as dateHasChanged,i as dateIsOutsideRange,o as getCalendars,n as getInitialDate,r as getInitialDateShown,d as getMonthSelectOptions,l as getYearSelectOptions,c as isBackDisabled,g as isForwardDisabled,m as isSameDay,p as subtractMonth};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as o,jsx as i}from"react/jsx-runtime";import{c as n}from"../../../clsx-BeLtu-UY.js";import{useId as s}from"react";import{formatBytes as c}from"../../utilities/formatters/bytes/formatBytes.js";import"../../utilities/polymorphism/SlotComponent.js";import{Button as
|
|
1
|
+
import{jsxs as o,jsx as i}from"react/jsx-runtime";import{c as n}from"../../../clsx-BeLtu-UY.js";import{useId as s}from"react";import{formatBytes as c}from"../../utilities/formatters/bytes/formatBytes.js";import"../../utilities/polymorphism/SlotComponent.js";import{Button as r}from"../button/Button.js";import{useFileInputContext as t}from"../file-input/internal/fileInputContext.js";import{Flex as e}from"../flex/Flex.js";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/MinusIcon.js";import"../icon/icons/OpenInNewIcon.js";import"../icon/icons/PenIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import{TrashCanIcon as a}from"../icon/icons/TrashCanIcon.js";import"../icon/icons/WarningIcon.js";import"../../hooks/useId/useId.js";import{SupportLabel as m}from"../input-group/SupportLabel.js";import"../input-group/InputGroup.js";import{Link as l}from"../link/Link.js";import{Text as p}from"../typography/Text.js";import"../typography/Title.js";const j=j=>{const{children:I,hideThumbnail:f,className:u,fileName:h,fileType:d,fileSize:k,path:_,file:C,state:b,errorLabel:g="Feil",onRemove:w,variant:N="list",...y}=j,x=`jkl-file-preview-${s()}`,v=`${x}-support`,A=t(),L=d.startsWith("image/")&&(C?URL.createObjectURL(C):_),T=o("div",{id:x,className:n(u,"jkl-file",`jkl-file--${N}`),"data-state":b,...y,children:[o(e,{gap:"8",direction:"card"===N?"column":"row",alignItems:"card"===N?"start":"center",className:"jkl-file__content",children:[!f&&i("div",{className:"jkl-file__thumbnail","data-filetype":d,children:L&&i("img",{src:L,alt:""})}),o(e,{gap:"8",alignItems:"center",justifyContent:"space-between",className:"jkl-file__info",children:[_?i(p,{size:"s",className:"jkl-file__name",children:o(l,{href:_,children:[h," ",o("span",{className:"jkl-file__size",children:["(",c(k),")"]})]})}):o(p,{size:"s",className:"jkl-file__name",children:[h," ",o("span",{className:"jkl-file__size",children:["(",c(k),")"]})]}),w&&i(r,{variant:"ghost",className:"jkl-file__button",onClick:w,title:`Fjern ${h}`,icon:i(a,{})})]})]}),"error"===b&&g&&i(m,{className:"jkl-file__support-label",id:v,label:g,labelType:"error"})]});return A?i("li",{children:T}):T};export{j as File};
|
|
2
2
|
//# sourceMappingURL=File.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.js","sources":["../../../../src/components/file/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport
|
|
1
|
+
{"version":3,"file":"File.js","sources":["../../../../src/components/file/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentProps, type FC, useId } from \"react\";\nimport { formatBytes } from \"../../utilities/index.js\";\nimport { Button } from \"../button/index.js\";\nimport { useFileInputContext } from \"../file-input/internal/fileInputContext.js\";\nimport { Flex } from \"../flex/index.js\";\nimport { TrashCanIcon } from \"../icon/index.js\";\nimport { SupportLabel } from \"../input-group/index.js\";\nimport { Link } from \"../link/index.js\";\nimport { Text } from \"../typography/index.js\";\nimport type { FileProps } from \"./types.js\";\n\nexport const File: FC<FileProps & ComponentProps<\"div\">> = (props) => {\n const {\n children: _,\n hideThumbnail,\n className,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n state,\n errorLabel = \"Feil\",\n onRemove,\n variant = \"list\",\n ...rest\n } = props;\n\n const id = `jkl-file-preview-${useId()}`;\n const supportId = `${id}-support`;\n\n const context = useFileInputContext();\n\n const imageSrc =\n fileType.startsWith(\"image/\") &&\n (file ? URL.createObjectURL(file) : path);\n\n const fileComponent = (\n <div\n id={id}\n className={clsx(className, \"jkl-file\", `jkl-file--${variant}`)}\n data-state={state}\n {...rest}\n >\n <Flex\n gap=\"8\"\n direction={variant === \"card\" ? \"column\" : \"row\"}\n alignItems={variant === \"card\" ? \"start\" : \"center\"}\n className={\"jkl-file__content\"}\n >\n {!hideThumbnail && (\n <div\n className=\"jkl-file__thumbnail\"\n data-filetype={fileType}\n >\n {imageSrc && <img src={imageSrc} alt=\"\" />}\n </div>\n )}\n <Flex\n gap=\"8\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n className=\"jkl-file__info\"\n >\n {path ? (\n <Text size=\"s\" className=\"jkl-file__name\">\n <Link href={path}>\n {fileName}{\" \"}\n <span className=\"jkl-file__size\">\n ({formatBytes(fileSize)})\n </span>\n </Link>\n </Text>\n ) : (\n <Text size=\"s\" className=\"jkl-file__name\">\n {fileName}{\" \"}\n <span className=\"jkl-file__size\">\n ({formatBytes(fileSize)})\n </span>\n </Text>\n )}\n {onRemove && (\n <Button\n variant={\"ghost\"}\n className=\"jkl-file__button\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n icon={<TrashCanIcon />}\n />\n )}\n </Flex>\n </Flex>\n\n {state === \"error\" && errorLabel && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={errorLabel}\n labelType={\"error\"}\n />\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["File","props","children","_","hideThumbnail","className","fileName","fileType","fileSize","path","file","state","errorLabel","onRemove","variant","rest","id","useId","supportId","context","useFileInputContext","imageSrc","startsWith","URL","createObjectURL","fileComponent","jsxs","clsx","Flex","gap","direction","alignItems","jsx","src","alt","justifyContent","Text","size","Link","href","formatBytes","Button","onClick","title","icon","TrashCanIcon","SupportLabel","label","labelType"],"mappings":"iiEAYO,MAAMA,EAA+CC,IACxD,MACIC,SAAUC,EACVC,cAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,MAAAA,EACAC,WAAAA,EAAa,OACbC,SAAAA,EACAC,QAAAA,EAAU,UACPC,GACHd,EAEEe,EAAK,oBAAoBC,MACzBC,EAAY,GAAGF,YAEfG,EAAUC,IAEVC,EACFd,EAASe,WAAW,YACnBZ,EAAOa,IAAIC,gBAAgBd,GAAQD,GAElCgB,EACFC,EAAC,MAAA,CACGV,GAAAA,EACAX,UAAWsB,EAAKtB,EAAW,WAAY,aAAaS,KACpD,aAAYH,KACRI,EAEJb,SAAA,CAAAwB,EAACE,EAAA,CACGC,IAAI,IACJC,UAAuB,SAAZhB,EAAqB,SAAW,MAC3CiB,WAAwB,SAAZjB,EAAqB,QAAU,SAC3CT,UAAW,oBAEVH,SAAA,EAACE,GACE4B,EAAC,MAAA,CACG3B,UAAU,sBACV,gBAAeE,EAEdL,YAAY8B,EAAC,MAAA,CAAIC,IAAKZ,EAAUa,IAAI,OAG7CR,EAACE,EAAA,CACGC,IAAI,IACJE,WAAW,SACXI,eAAe,gBACf9B,UAAU,iBAETH,SAAA,CAAAO,EACGuB,EAACI,GAAKC,KAAK,IAAIhC,UAAU,iBACrBH,SAAAwB,EAACY,EAAA,CAAKC,KAAM9B,EACPP,SAAA,CAAAI,EAAU,IACXoB,EAAC,OAAA,CAAKrB,UAAU,iBAAiBH,SAAA,CAAA,IAC3BsC,EAAYhC,GAAU,YAKpCkB,EAACU,GAAKC,KAAK,IAAIhC,UAAU,iBACpBH,SAAA,CAAAI,EAAU,IACXoB,EAAC,OAAA,CAAKrB,UAAU,iBAAiBH,SAAA,CAAA,IAC3BsC,EAAYhC,GAAU,UAInCK,GACGmB,EAACS,EAAA,CACG3B,QAAS,QACTT,UAAU,mBACVqC,QAAS7B,EACT8B,MAAO,SAASrC,IAChBsC,OAAOC,EAAA,CAAA,WAMZ,UAAVlC,GAAqBC,GAClBoB,EAACc,EAAA,CACGzC,UAAU,0BACVW,GAAIE,EACJ6B,MAAOnC,EACPoC,UAAW,aAM3B,OAAO7B,EAAUa,EAAC,KAAA,CAAI9B,SAAAuB,IAAsBA"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { MouseEvent } from 'react';
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
export type FileProps = {
|
|
3
3
|
fileName: string;
|
|
4
4
|
fileType: string;
|
|
5
5
|
fileSize: number;
|
|
6
6
|
path?: string;
|
|
7
7
|
errorLabel?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Du kan skjule forhåndsvisning av bilde/filendelse for å spare plass
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
hideThumbnail?: boolean;
|
|
8
13
|
state?: "error" | "loading";
|
|
9
14
|
/**
|
|
10
15
|
* Velg hvordan filene skal vises for brukeren
|
|
@@ -17,4 +22,8 @@ export type FileProps = {
|
|
|
17
22
|
* Gjør det mulig å vise en knapp for fjerning av filene ved filopplasting
|
|
18
23
|
*/
|
|
19
24
|
onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Blir ikke brukt, vil fjernes i neste major-release
|
|
27
|
+
*/
|
|
28
|
+
children?: ReactNode;
|
|
20
29
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r,Fragment as l}from"react/jsx-runtime";import{c as
|
|
1
|
+
import{jsxs as e,jsx as r,Fragment as l}from"react/jsx-runtime";import{c as o}from"../../../clsx-BeLtu-UY.js";import"react";import{useId as s}from"../../hooks/useId/useId.js";import{Label as a}from"./Label.js";import{SupportLabel as i}from"./SupportLabel.js";const t=t=>{const{id:d,legend:p,labelProps:n,supportLabelProps:c,tooltip:m,className:u,children:b,helpLabel:f,errorLabel:j,description:h,"data-testautoid":g,...L}=t,x=s(d||"jkl-field-group",{generateSuffix:!d}),k=`${x}_support-label`,v=`${x}_description`,N=j||f,S=j?"error":f?"help":void 0,_=[h?v:void 0,N?k:void 0].filter(Boolean).join(" ")||void 0;return e("fieldset",{id:x,className:o("jkl-field-group",u),"data-testautoid":g,...L,"aria-describedby":_,children:[r("legend",{className:"jkl-field-group__legend",children:r(a,{...n,children:m?e(l,{children:[r("span",{style:{whiteSpace:"normal"},children:p})," ",m]}):p})}),h&&r("p",{className:"jkl-input-group-description",id:v,children:h}),b,(f||j)&&r(i,{...c,label:N,labelType:S,id:k})]})};export{t as FieldGroup};
|
|
2
2
|
//# sourceMappingURL=FieldGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroup.js","sources":["../../../../src/components/input-group/FieldGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label } from \"./Label.js\";\nimport { SupportLabel } from \"./SupportLabel.js\";\nimport type { FieldGroupProps } from \"./types.js\";\n\nexport const FieldGroup: FC<FieldGroupProps> = (props) => {\n const {\n id,\n legend,\n labelProps,\n supportLabelProps,\n tooltip,\n className,\n children,\n helpLabel,\n errorLabel,\n description,\n \"data-testautoid\": testAutoId,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-field-group\", { generateSuffix: !id });\n const supportId = `${uid}_support-label`;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy
|
|
1
|
+
{"version":3,"file":"FieldGroup.js","sources":["../../../../src/components/input-group/FieldGroup.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { Label } from \"./Label.js\";\nimport { SupportLabel } from \"./SupportLabel.js\";\nimport type { FieldGroupProps } from \"./types.js\";\n\nexport const FieldGroup: FC<FieldGroupProps> = (props) => {\n const {\n id,\n legend,\n labelProps,\n supportLabelProps,\n tooltip,\n className,\n children,\n helpLabel,\n errorLabel,\n description,\n \"data-testautoid\": testAutoId,\n ...rest\n } = props;\n\n const uid = useId(id || \"jkl-field-group\", { generateSuffix: !id });\n const supportId = `${uid}_support-label`;\n const descriptionId = `${uid}_description`;\n\n const supportText = errorLabel || helpLabel;\n const supportTextType = errorLabel\n ? \"error\"\n : helpLabel\n ? \"help\"\n : undefined;\n\n const describedBy =\n [\n description ? descriptionId : undefined,\n supportText ? supportId : undefined,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n return (\n <fieldset\n id={uid}\n className={clsx(\"jkl-field-group\", className)}\n data-testautoid={testAutoId}\n {...rest}\n aria-describedby={describedBy}\n >\n <legend className=\"jkl-field-group__legend\">\n <Label {...labelProps}>\n {tooltip ? (\n <>\n <span style={{ whiteSpace: \"normal\" }}>\n {legend}\n </span>\n {\"\\u00A0\"}\n {tooltip}\n </>\n ) : (\n legend\n )}\n </Label>\n </legend>\n {description && (\n <p className=\"jkl-input-group-description\" id={descriptionId}>\n {description}\n </p>\n )}\n {children}\n {(helpLabel || errorLabel) && (\n <SupportLabel\n {...supportLabelProps}\n label={supportText}\n labelType={supportTextType}\n id={supportId}\n />\n )}\n </fieldset>\n );\n};\n"],"names":["FieldGroup","props","id","legend","labelProps","supportLabelProps","tooltip","className","children","helpLabel","errorLabel","description","testAutoId","rest","uid","useId","generateSuffix","supportId","descriptionId","supportText","supportTextType","describedBy","filter","Boolean","join","jsxs","clsx","jsx","Label","Fragment","style","whiteSpace","SupportLabel","label","labelType"],"mappings":"mQAOO,MAAMA,EAAmCC,IAC5C,MACIC,GAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,YAAAA,EACA,kBAAmBC,KAChBC,GACHZ,EAEEa,EAAMC,EAAMb,GAAM,kBAAmB,CAAEc,gBAAiBd,IACxDe,EAAY,GAAGH,kBACfI,EAAgB,GAAGJ,gBAEnBK,EAAcT,GAAcD,EAC5BW,EAAkBV,EAClB,QACAD,EACE,YACA,EAEFY,EACF,CACIV,EAAcO,OAAgB,EAC9BC,EAAcF,OAAY,GAEzBK,OAAOC,SACPC,KAAK,WAAQ,EAEtB,OACIC,EAAC,WAAA,CACGvB,GAAIY,EACJP,UAAWmB,EAAK,kBAAmBnB,GACnC,kBAAiBK,KACbC,EACJ,mBAAkBQ,EAElBb,SAAA,CAAAmB,EAAC,SAAA,CAAOpB,UAAU,0BACdC,SAAAmB,EAACC,MAAUxB,EACNI,WACGiB,EAAAI,EAAA,CACIrB,SAAA,CAAAmB,EAAC,QAAKG,MAAO,CAAEC,WAAY,UACtBvB,SAAAL,IAEJ,IACAG,KAGLH,MAIXQ,GACGgB,EAAC,IAAA,CAAEpB,UAAU,8BAA8BL,GAAIgB,EAC1CV,SAAAG,IAGRH,GACCC,GAAaC,IACXiB,EAACK,EAAA,IACO3B,EACJ4B,MAAOd,EACPe,UAAWd,EACXlB,GAAIe"}
|
|
@@ -6,6 +6,9 @@ export interface FieldGroupProps extends DataTestAutoId, FieldsetHTMLAttributes<
|
|
|
6
6
|
supportLabelProps?: Omit<SupportLabelProps, "id" | "errorLabel" | "helpLabel">;
|
|
7
7
|
tooltip?: ReactNode;
|
|
8
8
|
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Bruk heller `description`.
|
|
11
|
+
*/
|
|
9
12
|
helpLabel?: string;
|
|
10
13
|
errorLabel?: string;
|
|
11
14
|
description?: string;
|
|
@@ -21,6 +24,9 @@ export type InputGroupProps = WithOptionalChildren & DataTestAutoId & {
|
|
|
21
24
|
"data-testid"?: string;
|
|
22
25
|
"data-size"?: Size;
|
|
23
26
|
errorLabel?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Bruk heller `description`.
|
|
29
|
+
*/
|
|
24
30
|
helpLabel?: ReactNode;
|
|
25
31
|
inline?: boolean;
|
|
26
32
|
label: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../../../../node_modules/.pnpm/nanoid@5.1.
|
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../../../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/url-alphabet/index.js","../../../../../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/index.browser.js","../../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["export let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","\n\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet } from './url-alphabet/index.js'\n\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let j = size\n while (j--) {\n id += alphabet[bytes[j] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n if (bytes[j] < safeByteCutoff) {\n id += alphabet[bytes[j] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\n\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\n\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import clsx from \"clsx\";\nimport { nanoid } from \"nanoid\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { usePreviousValue } from \"../../hooks/usePreviousValue/usePreviousValue.js\";\nimport type { InjectedProps } from \"./TabList.js\";\nimport type { TabListProps, TabPanelProps, TabsProps } from \"./types.js\";\n\n/**\n * Konteiner for et grensesnitt hvor man kan tabbe mellom innhold.\n * Må inneholde en TabList etterfulgt av en eller flere TabPanel.\n *\n * Docs: https://jokul.fremtind.no/komponenter/tabs\n */\nexport const Tabs = ({ onChange, defaultTab, ...props }: TabsProps) => {\n const [activeIndex, setActiveIndex] = useState(defaultTab ?? 0);\n\n const previousTabIndex = usePreviousValue(activeIndex);\n\n useEffect(() => {\n if (\n previousTabIndex !== undefined &&\n previousTabIndex !== activeIndex &&\n onChange\n ) {\n onChange(activeIndex);\n }\n }, [onChange, previousTabIndex, activeIndex]);\n\n const [tabIDs, setTabIDs] = useState<string[]>([]);\n const [tabPanelIDs, setTabPanelIds] = useState<string[]>([]);\n\n const resolveIDs = useCallback(() => {\n const tabList = React.Children.toArray(props.children)[0];\n\n if (!React.isValidElement(tabList)) return;\n\n React.Children.forEach(tabList.props.children, (tab) => {\n if (!React.isValidElement(tab)) return;\n\n setTabIDs((prev) => [...prev, `jkl-tab-${nanoid(8)}`]);\n setTabPanelIds((prev) => [...prev, `jkl-tabpanel-${nanoid(8)}`]);\n });\n }, [props.children]);\n\n const renderTabList = () => {\n const tabList = React.Children.toArray(props.children)[0];\n\n if (!React.isValidElement<TabListProps & InjectedProps>(tabList))\n return;\n\n return React.cloneElement<TabListProps & InjectedProps>(tabList, {\n activeIndex,\n setActiveIndex,\n tabIDs,\n tabPanelIDs,\n });\n };\n\n const renderTabPanels = () => {\n return React.Children.map(props.children, (child, childIndex) => {\n if (\n !React.isValidElement<\n TabPanelProps & React.HTMLAttributes<HTMLDivElement>\n >(child) ||\n childIndex === 0\n )\n return;\n\n const tabPanelIndex = childIndex - 1;\n\n return tabPanelIndex === activeIndex\n ? React.cloneElement<\n TabPanelProps & React.HTMLAttributes<HTMLDivElement>\n >(child, {\n \"aria-labelledby\": tabIDs[tabPanelIndex],\n id: tabPanelIDs[tabPanelIndex],\n })\n : null;\n });\n };\n\n useEffect(() => {\n resolveIDs();\n }, [resolveIDs]);\n\n return (\n <div {...props} className={clsx(\"jkl-tabs\", props.className)}>\n {renderTabList()}\n {renderTabPanels()}\n </div>\n );\n};\n"],"names":["nanoid","size","id","bytes","crypto","getRandomValues","Uint8Array","Tabs","onChange","defaultTab","props","activeIndex","setActiveIndex","useState","previousTabIndex","usePreviousValue","useEffect","tabIDs","setTabIDs","tabPanelIDs","setTabPanelIds","resolveIDs","useCallback","tabList","React","Children","toArray","children","isValidElement","forEach","tab","prev","jsxs","className","clsx","cloneElement","renderTabList","map","child","childIndex","tabPanelIndex"],"mappings":"+OAAO,ICiDIA,EAAS,CAACC,EAAO,MAC1B,IAAIC,EAAK,GACLC,EAAQC,OAAOC,gBAAgB,IAAIC,WAAYL,GAAQ,IAC3D,KAAOA,KACLC,GDpDF,mECoDwC,GAAdC,EAAMF,IAEhC,OAAOC,GC1CF,MAAMK,EAAO,EAAGC,SAAAA,EAAUC,WAAAA,KAAeC,MAC5C,MAAOC,EAAaC,GAAkBC,EAASJ,GAAc,GAEvDK,EAAmBC,EAAiBJ,GAE1CK,EAAU,UAEmB,IAArBF,GACAA,IAAqBH,GACrBH,GAEAA,EAASG,IAEd,CAACH,EAAUM,EAAkBH,IAEhC,MAAOM,EAAQC,GAAaL,EAAmB,KACxCM,EAAaC,GAAkBP,EAAmB,IAEnDQ,EAAaC,EAAY,KAC3B,MAAMC,EAAUC,EAAMC,SAASC,QAAQhB,EAAMiB,UAAU,GAElDH,EAAMI,eAAeL,IAE1BC,EAAMC,SAASI,QAAQN,EAAQb,MAAMiB,SAAWG,IACvCN,EAAMI,eAAeE,KAE1BZ,EAAWa,GAAS,IAAIA,EAAM,WAAW/B,EAAO,OAChDoB,EAAgBW,GAAS,IAAIA,EAAM,gBAAgB/B,EAAO,WAE/D,CAACU,EAAMiB,WAuCV,OAAAX,EAAU,KACNK,KACD,CAACA,IAGAW,EAAC,UAAQtB,EAAOuB,UAAWC,EAAK,WAAYxB,EAAMuB,WAC7CN,SAAA,CA3Ca,MAClB,MAAMJ,EAAUC,EAAMC,SAASC,QAAQhB,EAAMiB,UAAU,GAEvD,GAAKH,EAAMI,eAA6CL,GAGxD,OAAOC,EAAMW,aAA2CZ,EAAS,CAC7DZ,YAAAA,EACAC,eAAAA,EACAK,OAAAA,EACAE,YAAAA,KAiCCiB,GA5BEZ,EAAMC,SAASY,IAAI3B,EAAMiB,SAAU,CAACW,EAAOC,KAC9C,IACKf,EAAMI,eAELU,IACa,IAAfC,EAEA,OAEJ,MAAMC,EAAgBD,EAAa,EAEnC,OAAOC,IAAkB7B,EACnBa,EAAMW,aAEJG,EAAO,CACL,kBAAmBrB,EAAOuB,GAC1BtC,GAAIiB,EAAYqB,KAEpB","x_google_ignoreList":[0,1]}
|