DatePicker
Datovelgeren gir brukerne mulighet til å skrive inn eller velge en dato. Ledeteksten beskriver hvilken dato brukeren skal fylle inn. To datovelgere kan brukes sammen for å angi perioder.
man | tir | ons | tor | fre | lør | søn |
---|---|---|---|---|---|---|
Du finner et eksempel på datovelger brukt i skjemakontekst under Profil og Skjemadesign. Koden til eksempelet finner du på GitHub.
Typer og bruk
- Enkel datovelger, til når brukeren skal velge en dato som er nær dagens dato
- Utvidet datovelger, til når brukeren skal velge en dato som ligger mer enn ett år frem eller tilbake i tid
Vi kan også bruke to datovelgere, når vi vil at brukeren skal angi en periode med fra- og tildato. For eksempel "Hvor lenge var du syk da du var på ferie? Velg dato fra og til".
Tekst og validering
Velg størrelse på ledeteksten etter prinsippene for skjemadesign. Bruk en kort og tydelig ledetekst, som forteller hva brukeren skal velge. Hvis det trengs, kan du også gi mer forklaring med en hjelpetekst under feltet.
Hvis datovelgeren ikke validerer, vises en feilmelding, som forteller hva som er galt. Merk at feilmeldingen erstatter en eventuell hjelpetekst, slik at den feilmeldingen du lager også må fortelle hva hjelpeteksten var.
man | tir | ons | tor | fre | lør | søn |
---|---|---|---|---|---|---|
Riktig
Hjelpetekst i feilmelding
man | tir | ons | tor | fre | lør | søn |
---|---|---|---|---|---|---|
Feil
Feilmelding uten hjelp
React API
Her finner du en oversikt over props på komponentene i pakken.
Prop | Beskrivelse | Standardverdi | Påkrevd | Type |
---|---|---|---|---|
id | Settes på rotnivå. | ingen | Ikke påkrevd | string | undefined |
className | Settes på rotnivå. | ingen | Ikke påkrevd | string | undefined |
label | "Velg dato" | Ikke påkrevd | string | undefined | |
labelProps | Bruk labelProps for å sette props som `variant` og `srOnly`. @example ```tsx <DatePicker labelProps={{ srOnly: true }} /> ``` | ingen | Ikke påkrevd | Omit<LabelProps, "children" | "forceCompact"> | undefined |
defaultValue | dd.mm.åååå Dersom komponenten ikke er _controlled_, send inn ønsket standardverdi her (hvis noen). | undefined // tomt skjemafelt | Ikke påkrevd | string | undefined |
defaultShow | Styr om du vil at kalenderen skal starte åpen. | false | Ikke påkrevd | boolean | undefined |
value | dd.mm.åååå Verdien til inputfeltet. | ingen | Ikke påkrevd | string | undefined |
disableBeforeDate | dd.mm.åååå Skru av knapper i kalenderen før denne datoen, og gi valideringsfeil om dato som har blitt skrevet inn er utenfor. | ingen | Ikke påkrevd | string | undefined |
disableAfterDate | dd.mm.åååå Skru av knapper i kalenderen etter denne datoen, og gi valideringsfeil om dato som har blitt skrevet inn er utenfor. | ingen | Ikke påkrevd | string | undefined |
name | Settes på inputfeltet. | ingen | Ikke påkrevd | string | undefined |
helpLabel | Hjelpetekst som vises under inputfeltet. | ingen | Ikke påkrevd | string | undefined |
errorLabel | Hvis datovelgeren har valideringsfeil må dette feltet settes. Inputfeltet merkes som ugyldig og teksten erstatter en eventuell hjelpetekst. | ingen | Ikke påkrevd | string | undefined |
invalid | Merk som ugyldig uten å sende inn en errorLabel. NB! Brukes kun i tilfeller der valideringsfeil dukker opp andre steder, for eksempel i en FieldGroup. | ingen | Ikke påkrevd | boolean | undefined |
forceCompact | Bruk kompakt layout på skjemafeltet. | ingen | Ikke påkrevd | boolean | undefined |
extended | Vis et inputfelt og en select for å navigere mellom år og måneder, i stedet for piler frem og tilbake. Kan være nyttig om brukeren forventes å hoppe langt frem eller tilbake i tid. | false | Ikke påkrevd | boolean | undefined |
days | Om du ønsker andre labels for ukedagene kan du gi de her. | ingen | Ikke påkrevd | string[] | undefined |
months | Om du ønsker andre labels for måneder kan du gi de her. | ingen | Ikke påkrevd | string[] | undefined |
monthLabel | Overstyr hvordan vi omtaler "Måned". | "Måned" | Ikke påkrevd | string | undefined |
yearLabel | Overstyr hvordan vi omtaler "År". | "År" | Ikke påkrevd | string | undefined |
placeholder | Vises i inputfeltet hvis det ikke har noen input, som hint for datoformat. | "dd.mm.åååå" | Ikke påkrevd | string | undefined |
width | Bredden på inputfeltet, tilpasset typisk bredde for en dato i formatet `dd.mm.åååå`. | "11.5rem" | Ikke påkrevd | string | undefined |
onChange | Kalles ved change-event fra datovelgerens inputfelt. Verdien fra selve eventet vil alltid være teksten fra inputfeltet. Det er _ikke_ garantert at verdien fra `event.target.value` er en gyldig dato, eller i datoformat. Andre parameter vil enten være en gyldig `Date` eller `null`. Tredje parameter har informasjon om validering, men du kan også gjøre validering selv rett på `event.target.value` med utility-funksjoner som eksporteres fra pakka (se eksempel lenger ned). Kalles også når brukeren velger en dato fra kalendervisningen. Kallet prøver å simulere et vanlig change-event så nært som mulig. Bruk meta-objektet for å se om det er valideringsfeil, og i så fal hvilken type feil: - ugyldig format på tekst - dato utenfor minimum tillatte dato (satt med `disableBeforeDate`) - dato utenfor maksimum tillatte dato (satt med `disableAfterDate`) @example ```tsx <DatePicker value={value} onChange={(e, date, meta) => { setValue(e.target.value); console.log("onChange", { event: e, date, meta, }); }} /> ``` @example ```tsx import { DatePicker, formatInput, isCorrectFormat, isWithinUpperBound, isWithinLowerBound, parseDateString } from "@fremtind/jkl-datepicker-react"; import { formatDate } from "@fremtind/jkl-formatters-util"; <DatePicker label="Fødselsdato" errorLabel={formState.errors.fodselsdato?.message} disableBefore="01.01.1970" disableAfter={formatInput(new Date())} {...register("fodselsdato", { required: "Du må fylle ut fødselsdato", validate: { isCorrectFormat: (v) => isCorrectFormat(v) || `Datoen må være skrevet i formen ${formatDate(new Date())} eller kortformat`, withinLowerBound: (v) => isWithinLowerBound(v, parseDateString("01.01.1970") || "Datoen må være før 01.01.1970"", withinUpperBound: (v) => isWithinUpperBound(v, new Date()) || `Datoen må være før ${formatDate(new Date())}`, }, })} /> ``` | ingen | Ikke påkrevd | DatePickerChangeEventHandler | undefined |
onFocus | Kalles ved focus-event fra datovelgerens inputfelt. @example ```tsx <DatePicker onFocus={(e, date, meta) => { console.log("onFocus", { event: e, date, meta, }); }} /> ``` | ingen | Ikke påkrevd | DatePickerBlurEventHandler | undefined |
onBlur | Kalles ved blur-event fra datovelgerens inputfelt, og kommer når fokus flyttes ut av skjemaelementet. **NB!** Dette inkluderer når fokus flyttes inn i kalenderen, eller til kalenderknappen! Om du ønsker å gjøre ting når brukeren går videre fra hele DatePicker: 1. Ha en onBlur på DatePicker, men ignorere events når fokus er inni DatePicker 2. Ha en onBlur på DatePicker sin action-prop (kalenderknappen), og gjøre det samme Hjelpefunksjonen isBlurTargetOutside hjelper med detaljene. @example ```tsx import { DatePicker, isBlurTargetOutside } from "@fremtind/jkl-datepicker-react"; <DatePicker onBlur={(e, date, meta) => { // Ignorer blurs som går til kalenderknapper if (isBlurTargetOutside(e)) { console.log("onBlur"); } }} action={{ onBlur: (e) => { // Ignorer blurs som går tilbake til inputfeltet if (isBlurTargetOutside(e)) { console.log("action.onBlur"); } }, }} /> ``` | ingen | Ikke påkrevd | DatePickerBlurEventHandler | undefined |
onKeyDown | Kalles ved onKeyDown på datovelgerens inputfelt. Dersom du trenger å fange opp alle tastetrykk, inkludert Tab videre til knappen for å åpne/lukke kalenderen, så kan du bruke dette eventet. @deprecated Eventet har mye overlapp med onChange, men var tidligere eneste metode for å få tilbakemelding ved tastetrykk i inputfeltet. Foretrekk onChange for ny kode. | ingen | Ikke påkrevd | DatePickerKeyDownEventHandler | undefined |
action | Lar deg sette lyttere på kalenderknappen i skjemafeltet. | ingen | Ikke påkrevd | DatePickerAction | undefined |
showCalendarLabel | ingen | Ikke påkrevd | string | undefined | |
hideCalendarLabel | ingen | Ikke påkrevd | string | undefined | |
data-testautoid | ingen | Ikke påkrevd | string | undefined |
Arvede props
Prop | Beskrivelse | Standardverdi | Påkrevd | Type |
---|---|---|---|---|
ref | ingen | Ikke påkrevd | Ref<HTMLInputElement> | undefined | |
key | ingen | Ikke påkrevd | Key | null | undefined |
Arvede props
Prop | Beskrivelse | Standardverdi | Påkrevd | Type |
---|---|---|---|---|
toString | Returns a string representation of a string. | ingen | Ikke påkrevd | () => string |
charAt | Returns the character at the specified index. @param pos The zero-based index of the desired character. | ingen | Påkrevd | (pos: number) => string |
charCodeAt | Returns the Unicode value of the character at the specified location. @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. | ingen | Påkrevd | (index: number) => number |
concat | Returns a string that contains the concatenation of two or more strings. @param strings The strings to append to the end of the string. | ingen | Påkrevd | (...strings: string[]) => string |
indexOf | Returns the position of the first occurrence of a substring. @param searchString The substring to search for in the string @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => number |
lastIndexOf | Returns the last occurrence of a substring in the string. @param searchString The substring to search for. @param position The index at which to begin searching. If omitted, the search begins at the end of the string. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => number |
localeCompare | Determines whether two strings are equivalent in the current locale. Determines whether two strings are equivalent in the current or specified locale. @param that String to compare to target string @param that String to compare to target string @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. | ingen | Påkrevd | { (that: string): number; (that: string, locales?: string | string[] | undefined, options?: CollatorOptions | undefined): number; } |
match | Matches a string with a regular expression, and returns an array containing the results of that search. Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found. @param regexp A variable name or string literal containing the regular expression pattern and flags. @param matcher An object that supports being matched against. | ingen | Påkrevd | { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } |
replace | Replaces text in a string, using a regular expression or search string. Replaces first match with string or all matches with RegExp. Replaces text in a string, using an object that supports replacement within a string. @param searchValue A string to search for. @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. @param searchValue A string to search for. @param replacer A function that returns the replacement text. @param searchValue A string or RegExp search value. @param replaceValue A string containing the text to replace for match. @param searchValue A object can search for and replace matches within a string. @param replacer A function that returns the replacement text. | ingen | Påkrevd | { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { ...; }, replaceValue: string): string; (searchValue: { ...; }, replacer: (substring: string, ...args: any[]) => string): string; } |
search | Finds the first substring match in a regular expression search. @param regexp The regular expression pattern and applicable flags. @param searcher An object which supports searching within a string. | ingen | Påkrevd | { (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; } |
slice | Returns a section of a string. @param start The index to the beginning of the specified portion of stringObj. @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of stringObj. | ingen | Påkrevd | (start?: number | undefined, end?: number | undefined) => string |
split | Split a string into substrings using the specified separator and return them as an array. @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. @param limit A value used to limit the number of elements returned in the array. @param splitter An object that can split a string. @param limit A value used to limit the number of elements returned in the array. | ingen | Påkrevd | { (separator: string | RegExp, limit?: number | undefined): string[]; (splitter: { [Symbol.split](string: string, limit?: number | undefined): string[]; }, limit?: number | undefined): string[]; } |
substring | Returns the substring at the specified location within a String object. @param start The zero-based index number indicating the beginning of the substring. @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. If end is omitted, the characters from start through the end of the original string are returned. | ingen | Påkrevd | (start: number, end?: number | undefined) => string |
toLowerCase | Converts all the alphabetic characters in a string to lowercase. | ingen | Påkrevd | () => string |
toLocaleLowerCase | Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. | ingen | Påkrevd | (locales?: string | string[] | undefined) => string |
toUpperCase | Converts all the alphabetic characters in a string to uppercase. | ingen | Påkrevd | () => string |
toLocaleUpperCase | Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. | ingen | Påkrevd | (locales?: string | string[] | undefined) => string |
trim | Removes the leading and trailing white space and line terminator characters from a string. | ingen | Påkrevd | () => string |
length | Returns the length of a String object. | ingen | Påkrevd | number |
substr | Gets a substring beginning at the specified location and having the specified length. @deprecated A legacy feature for browser compatibility @param from The starting position of the desired substring. The index of the first character in the string is zero. @param length The number of characters to include in the returned substring. | ingen | Påkrevd | (from: number, length?: number | undefined) => string |
valueOf | Returns the primitive value of the specified object. | ingen | Ikke påkrevd | () => string |
codePointAt | Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point value of the UTF-16 encoded code point starting at the string element at position pos in the String resulting from converting this object to a String. If there is no element at that position, the result is undefined. If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. | ingen | Påkrevd | (pos: number) => number | undefined |
includes | Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false. @param searchString search string @param position If position is undefined, 0 is assumed, so as to search all of the String. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => boolean |
endsWith | Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false. | ingen | Påkrevd | (searchString: string, endPosition?: number | undefined) => boolean |
normalize | Returns the String value result of normalizing the string into the normalization form named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default is "NFC" @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default is "NFC" | ingen | Påkrevd | { (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string | undefined): string; } |
repeat | Returns a String value that is made from count copies appended together. If count is 0, the empty string is returned. @param count number of copies to append | ingen | Påkrevd | (count: number) => string |
startsWith | Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => boolean |
anchor | Returns an `<a>` HTML anchor element and sets the name attribute to the text value @deprecated A legacy feature for browser compatibility @param name | ingen | Påkrevd | (name: string) => string |
big | Returns a `<big>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
blink | Returns a `<blink>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
bold | Returns a `<b>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
fixed | Returns a `<tt>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
fontcolor | Returns a `<font>` HTML element and sets the color attribute value @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | (color: string) => string |
fontsize | Returns a `<font>` HTML element and sets the size attribute value @deprecated A legacy feature for browser compatibility @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | { (size: number): string; (size: string): string; } |
italics | Returns an `<i>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
link | Returns an `<a>` HTML element and sets the href attribute value @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | (url: string) => string |
small | Returns a `<small>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
strike | Returns a `<strike>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
sub | Returns a `<sub>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
sup | Returns a `<sup>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
padStart | Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the start (left) of the current string. @param maxLength The length of the resulting string once the current string has been padded. If this parameter is smaller than the current string's length, the current string will be returned as it is. @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied. The default value for this parameter is " " (U+0020). | ingen | Påkrevd | (maxLength: number, fillString?: string | undefined) => string |
padEnd | Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string. @param maxLength The length of the resulting string once the current string has been padded. If this parameter is smaller than the current string's length, the current string will be returned as it is. @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied. The default value for this parameter is " " (U+0020). | ingen | Påkrevd | (maxLength: number, fillString?: string | undefined) => string |
trimEnd | Removes the trailing white space and line terminator characters from a string. | ingen | Påkrevd | () => string |
trimStart | Removes the leading white space and line terminator characters from a string. | ingen | Påkrevd | () => string |
trimLeft | Removes the leading white space and line terminator characters from a string. @deprecated A legacy feature for browser compatibility. Use `trimStart` instead | ingen | Påkrevd | () => string |
trimRight | Removes the trailing white space and line terminator characters from a string. @deprecated A legacy feature for browser compatibility. Use `trimEnd` instead | ingen | Påkrevd | () => string |
matchAll | Matches a string with a regular expression, and returns an iterable of matches containing the results of that search. @param regexp A variable name or string literal containing the regular expression pattern and flags. | ingen | Påkrevd | (regexp: RegExp) => IterableIterator<RegExpMatchArray> |
__@iterator@55 | Iterator | ingen | Påkrevd | () => IterableIterator<string> |
at | Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array. | ingen | Påkrevd | (index: number) => string | undefined |
Arvede props
Prop | Beskrivelse | Standardverdi | Påkrevd | Type |
---|---|---|---|---|
toString | Returns a string representation of a date. The format of the string depends on the locale. | ingen | Ikke påkrevd | () => string |
toDateString | Returns a date as a string value. | ingen | Påkrevd | () => string |
toTimeString | Returns a time as a string value. | ingen | Påkrevd | () => string |
toLocaleString | Returns a value as a string value appropriate to the host environment's current locale. Converts a date and time to a string by using the current or specified locale. @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. @param options An object that contains one or more properties that specify comparison options. @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. @param options An object that contains one or more properties that specify comparison options. | ingen | Ikke påkrevd | { (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?: DateTimeFormatOptions | undefined): string; } |
toLocaleDateString | Returns a date as a string value appropriate to the host environment's current locale. Converts a date to a string by using the current or specified locale. @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. @param options An object that contains one or more properties that specify comparison options. @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. @param options An object that contains one or more properties that specify comparison options. | ingen | Påkrevd | { (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?: DateTimeFormatOptions | undefined): string; } |
toLocaleTimeString | Returns a time as a string value appropriate to the host environment's current locale. Converts a time to a string by using the current or specified locale. @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. @param options An object that contains one or more properties that specify comparison options. @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. @param options An object that contains one or more properties that specify comparison options. | ingen | Påkrevd | { (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; (locales?: LocalesArgument, options?: DateTimeFormatOptions | undefined): string; } |
valueOf | Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. | ingen | Ikke påkrevd | () => number |
getTime | Gets the time value in milliseconds. | ingen | Påkrevd | () => number |
getFullYear | Gets the year, using local time. | ingen | Påkrevd | () => number |
getUTCFullYear | Gets the year using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getMonth | Gets the month, using local time. | ingen | Påkrevd | () => number |
getUTCMonth | Gets the month of a Date object using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getDate | Gets the day-of-the-month, using local time. | ingen | Påkrevd | () => number |
getUTCDate | Gets the day-of-the-month, using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getDay | Gets the day of the week, using local time. | ingen | Påkrevd | () => number |
getUTCDay | Gets the day of the week using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getHours | Gets the hours in a date, using local time. | ingen | Påkrevd | () => number |
getUTCHours | Gets the hours value in a Date object using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getMinutes | Gets the minutes of a Date object, using local time. | ingen | Påkrevd | () => number |
getUTCMinutes | Gets the minutes of a Date object using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getSeconds | Gets the seconds of a Date object, using local time. | ingen | Påkrevd | () => number |
getUTCSeconds | Gets the seconds of a Date object using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getMilliseconds | Gets the milliseconds of a Date, using local time. | ingen | Påkrevd | () => number |
getUTCMilliseconds | Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
getTimezoneOffset | Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). | ingen | Påkrevd | () => number |
setTime | Sets the date and time value in the Date object. @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. | ingen | Påkrevd | (time: number) => number |
setMilliseconds | Sets the milliseconds value in the Date object using local time. @param ms A numeric value equal to the millisecond value. | ingen | Påkrevd | (ms: number) => number |
setUTCMilliseconds | Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). @param ms A numeric value equal to the millisecond value. | ingen | Påkrevd | (ms: number) => number |
setSeconds | Sets the seconds value in the Date object using local time. @param sec A numeric value equal to the seconds value. @param ms A numeric value equal to the milliseconds value. | ingen | Påkrevd | (sec: number, ms?: number | undefined) => number |
setUTCSeconds | Sets the seconds value in the Date object using Universal Coordinated Time (UTC). @param sec A numeric value equal to the seconds value. @param ms A numeric value equal to the milliseconds value. | ingen | Påkrevd | (sec: number, ms?: number | undefined) => number |
setMinutes | Sets the minutes value in the Date object using local time. @param min A numeric value equal to the minutes value. @param sec A numeric value equal to the seconds value. @param ms A numeric value equal to the milliseconds value. | ingen | Påkrevd | (min: number, sec?: number | undefined, ms?: number | undefined) => number |
setUTCMinutes | Sets the minutes value in the Date object using Universal Coordinated Time (UTC). @param min A numeric value equal to the minutes value. @param sec A numeric value equal to the seconds value. @param ms A numeric value equal to the milliseconds value. | ingen | Påkrevd | (min: number, sec?: number | undefined, ms?: number | undefined) => number |
setHours | Sets the hour value in the Date object using local time. @param hours A numeric value equal to the hours value. @param min A numeric value equal to the minutes value. @param sec A numeric value equal to the seconds value. @param ms A numeric value equal to the milliseconds value. | ingen | Påkrevd | (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number |
setUTCHours | Sets the hours value in the Date object using Universal Coordinated Time (UTC). @param hours A numeric value equal to the hours value. @param min A numeric value equal to the minutes value. @param sec A numeric value equal to the seconds value. @param ms A numeric value equal to the milliseconds value. | ingen | Påkrevd | (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number |
setDate | Sets the numeric day-of-the-month value of the Date object using local time. @param date A numeric value equal to the day of the month. | ingen | Påkrevd | (date: number) => number |
setUTCDate | Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). @param date A numeric value equal to the day of the month. | ingen | Påkrevd | (date: number) => number |
setMonth | Sets the month value in the Date object using local time. @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. | ingen | Påkrevd | (month: number, date?: number | undefined) => number |
setUTCMonth | Sets the month value in the Date object using Universal Coordinated Time (UTC). @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. | ingen | Påkrevd | (month: number, date?: number | undefined) => number |
setFullYear | Sets the year of the Date object using local time. @param year A numeric value for the year. @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. @param date A numeric value equal for the day of the month. | ingen | Påkrevd | (year: number, month?: number | undefined, date?: number | undefined) => number |
setUTCFullYear | Sets the year value in the Date object using Universal Coordinated Time (UTC). @param year A numeric value equal to the year. @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. @param date A numeric value equal to the day of the month. | ingen | Påkrevd | (year: number, month?: number | undefined, date?: number | undefined) => number |
toUTCString | Returns a date converted to a string using Universal Coordinated Time (UTC). | ingen | Påkrevd | () => string |
toISOString | Returns a date as a string value in ISO format. | ingen | Påkrevd | () => string |
toJSON | Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. | ingen | Påkrevd | (key?: any) => string |
getVarDate | ingen | Påkrevd | () => VarDate | |
__@toPrimitive@527 | Converts a Date object to a string. Converts a Date object to a number. Converts a Date object to a string or number. @param hint The strings "number", "string", or "default" to specify what primitive to return. @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". | ingen | Påkrevd | { (hint: "default"): string; (hint: "string"): string; (hint: "number"): number; (hint: string): string | number; } |
Arvede props
Prop | Beskrivelse | Standardverdi | Påkrevd | Type |
---|---|---|---|---|
toString | Returns a string representation of a string. | ingen | Ikke påkrevd | () => string |
charAt | Returns the character at the specified index. @param pos The zero-based index of the desired character. | ingen | Påkrevd | (pos: number) => string |
charCodeAt | Returns the Unicode value of the character at the specified location. @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. | ingen | Påkrevd | (index: number) => number |
concat | Returns a string that contains the concatenation of two or more strings. @param strings The strings to append to the end of the string. | ingen | Påkrevd | (...strings: string[]) => string |
indexOf | Returns the position of the first occurrence of a substring. @param searchString The substring to search for in the string @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => number |
lastIndexOf | Returns the last occurrence of a substring in the string. @param searchString The substring to search for. @param position The index at which to begin searching. If omitted, the search begins at the end of the string. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => number |
localeCompare | Determines whether two strings are equivalent in the current locale. Determines whether two strings are equivalent in the current or specified locale. @param that String to compare to target string @param that String to compare to target string @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. | ingen | Påkrevd | { (that: string): number; (that: string, locales?: string | string[] | undefined, options?: CollatorOptions | undefined): number; } |
match | Matches a string with a regular expression, and returns an array containing the results of that search. Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found. @param regexp A variable name or string literal containing the regular expression pattern and flags. @param matcher An object that supports being matched against. | ingen | Påkrevd | { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } |
replace | Replaces text in a string, using a regular expression or search string. Replaces first match with string or all matches with RegExp. Replaces text in a string, using an object that supports replacement within a string. @param searchValue A string to search for. @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. @param searchValue A string to search for. @param replacer A function that returns the replacement text. @param searchValue A string or RegExp search value. @param replaceValue A string containing the text to replace for match. @param searchValue A object can search for and replace matches within a string. @param replacer A function that returns the replacement text. | ingen | Påkrevd | { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { ...; }, replaceValue: string): string; (searchValue: { ...; }, replacer: (substring: string, ...args: any[]) => string): string; } |
search | Finds the first substring match in a regular expression search. @param regexp The regular expression pattern and applicable flags. @param searcher An object which supports searching within a string. | ingen | Påkrevd | { (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; } |
slice | Returns a section of a string. @param start The index to the beginning of the specified portion of stringObj. @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of stringObj. | ingen | Påkrevd | (start?: number | undefined, end?: number | undefined) => string |
split | Split a string into substrings using the specified separator and return them as an array. @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. @param limit A value used to limit the number of elements returned in the array. @param splitter An object that can split a string. @param limit A value used to limit the number of elements returned in the array. | ingen | Påkrevd | { (separator: string | RegExp, limit?: number | undefined): string[]; (splitter: { [Symbol.split](string: string, limit?: number | undefined): string[]; }, limit?: number | undefined): string[]; } |
substring | Returns the substring at the specified location within a String object. @param start The zero-based index number indicating the beginning of the substring. @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. If end is omitted, the characters from start through the end of the original string are returned. | ingen | Påkrevd | (start: number, end?: number | undefined) => string |
toLowerCase | Converts all the alphabetic characters in a string to lowercase. | ingen | Påkrevd | () => string |
toLocaleLowerCase | Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. | ingen | Påkrevd | (locales?: string | string[] | undefined) => string |
toUpperCase | Converts all the alphabetic characters in a string to uppercase. | ingen | Påkrevd | () => string |
toLocaleUpperCase | Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. | ingen | Påkrevd | (locales?: string | string[] | undefined) => string |
trim | Removes the leading and trailing white space and line terminator characters from a string. | ingen | Påkrevd | () => string |
length | Returns the length of a String object. | ingen | Påkrevd | number |
substr | Gets a substring beginning at the specified location and having the specified length. @deprecated A legacy feature for browser compatibility @param from The starting position of the desired substring. The index of the first character in the string is zero. @param length The number of characters to include in the returned substring. | ingen | Påkrevd | (from: number, length?: number | undefined) => string |
valueOf | Returns the primitive value of the specified object. | ingen | Ikke påkrevd | () => string |
codePointAt | Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point value of the UTF-16 encoded code point starting at the string element at position pos in the String resulting from converting this object to a String. If there is no element at that position, the result is undefined. If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. | ingen | Påkrevd | (pos: number) => number | undefined |
includes | Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false. @param searchString search string @param position If position is undefined, 0 is assumed, so as to search all of the String. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => boolean |
endsWith | Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false. | ingen | Påkrevd | (searchString: string, endPosition?: number | undefined) => boolean |
normalize | Returns the String value result of normalizing the string into the normalization form named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default is "NFC" @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default is "NFC" | ingen | Påkrevd | { (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string | undefined): string; } |
repeat | Returns a String value that is made from count copies appended together. If count is 0, the empty string is returned. @param count number of copies to append | ingen | Påkrevd | (count: number) => string |
startsWith | Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false. | ingen | Påkrevd | (searchString: string, position?: number | undefined) => boolean |
anchor | Returns an `<a>` HTML anchor element and sets the name attribute to the text value @deprecated A legacy feature for browser compatibility @param name | ingen | Påkrevd | (name: string) => string |
big | Returns a `<big>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
blink | Returns a `<blink>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
bold | Returns a `<b>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
fixed | Returns a `<tt>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
fontcolor | Returns a `<font>` HTML element and sets the color attribute value @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | (color: string) => string |
fontsize | Returns a `<font>` HTML element and sets the size attribute value @deprecated A legacy feature for browser compatibility @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | { (size: number): string; (size: string): string; } |
italics | Returns an `<i>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
link | Returns an `<a>` HTML element and sets the href attribute value @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | (url: string) => string |
small | Returns a `<small>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
strike | Returns a `<strike>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
sub | Returns a `<sub>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
sup | Returns a `<sup>` HTML element @deprecated A legacy feature for browser compatibility | ingen | Påkrevd | () => string |
padStart | Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the start (left) of the current string. @param maxLength The length of the resulting string once the current string has been padded. If this parameter is smaller than the current string's length, the current string will be returned as it is. @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied. The default value for this parameter is " " (U+0020). | ingen | Påkrevd | (maxLength: number, fillString?: string | undefined) => string |
padEnd | Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string. @param maxLength The length of the resulting string once the current string has been padded. If this parameter is smaller than the current string's length, the current string will be returned as it is. @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied. The default value for this parameter is " " (U+0020). | ingen | Påkrevd | (maxLength: number, fillString?: string | undefined) => string |
trimEnd | Removes the trailing white space and line terminator characters from a string. | ingen | Påkrevd | () => string |
trimStart | Removes the leading white space and line terminator characters from a string. | ingen | Påkrevd | () => string |
trimLeft | Removes the leading white space and line terminator characters from a string. @deprecated A legacy feature for browser compatibility. Use `trimStart` instead | ingen | Påkrevd | () => string |
trimRight | Removes the trailing white space and line terminator characters from a string. @deprecated A legacy feature for browser compatibility. Use `trimEnd` instead | ingen | Påkrevd | () => string |
matchAll | Matches a string with a regular expression, and returns an iterable of matches containing the results of that search. @param regexp A variable name or string literal containing the regular expression pattern and flags. | ingen | Påkrevd | (regexp: RegExp) => IterableIterator<RegExpMatchArray> |
__@iterator@55 | Iterator | ingen | Påkrevd | () => IterableIterator<string> |
at | Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array. | ingen | Påkrevd | (index: number) => string | undefined |
Arvede props
Prop | Beskrivelse | Standardverdi | Påkrevd | Type |
---|---|---|---|---|
relatedTarget | ingen | Påkrevd | (EventTarget & Element) | null | |
target | ingen | Påkrevd | EventTarget & (HTMLButtonElement | HTMLInputElement) | |
nativeEvent | ingen | Påkrevd | FocusEvent | |
currentTarget | ingen | Påkrevd | EventTarget & (HTMLButtonElement | HTMLInputElement) | |
bubbles | ingen | Påkrevd | boolean | |
cancelable | ingen | Påkrevd | boolean | |
defaultPrevented | ingen | Påkrevd | boolean | |
eventPhase | ingen | Påkrevd | number | |
isTrusted | ingen | Påkrevd | boolean | |
preventDefault | ingen | Påkrevd | () => void | |
isDefaultPrevented | ingen | Påkrevd | () => boolean | |
stopPropagation | ingen | Påkrevd | () => void | |
isPropagationStopped | ingen | Påkrevd | () => boolean | |
persist | ingen | Påkrevd | () => void | |
timeStamp | ingen | Påkrevd | number | |
type | ingen | Påkrevd | string |