Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ryddet opp i sirkulære dependencies #2366

Merged
merged 30 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0713304
:sparkles: Boilerplate
KenAJoh Sep 26, 2023
68e5f35
:art: Testbuild
KenAJoh Sep 26, 2023
edd2d83
:recycle: Bedre exports av utils
KenAJoh Sep 26, 2023
cb118c9
:recycle: Update imports
KenAJoh Sep 26, 2023
57ff42c
:recycle: Fikset root imports
KenAJoh Sep 26, 2023
46d9f69
:art: Hide examples from workspace
KenAJoh Sep 27, 2023
a0f1eab
Merge branch 'main' into next-appdir
KenAJoh Oct 11, 2023
dfae35c
:fire: Fjernet next appdir
KenAJoh Oct 11, 2023
427eb5b
:fire: Fjernet npm exports
KenAJoh Oct 11, 2023
279fedf
:art: Fikset default export av Select
KenAJoh Oct 11, 2023
956f579
:art: Datepicker dependencies
KenAJoh Oct 11, 2023
697d680
:art: Monthpicker deps
KenAJoh Oct 11, 2023
e54a4ea
:art: Monthpicker deps
KenAJoh Oct 11, 2023
f15bb6b
:art: Dropdown deps
KenAJoh Oct 11, 2023
d2c9b73
:art: Expansioncard context
KenAJoh Oct 11, 2023
7f91d88
:art: Checkbox types
KenAJoh Oct 11, 2023
dc6cd4a
:art: Radio types
KenAJoh Oct 11, 2023
fbd074b
:art: Form props
KenAJoh Oct 11, 2023
7db440c
:art: List deps
KenAJoh Oct 11, 2023
35902f9
:art: Modal deps
KenAJoh Oct 11, 2023
7c084a1
:art: Stepper deps
KenAJoh Oct 11, 2023
690cc60
:art: Table types
KenAJoh Oct 11, 2023
97193c0
:art: Tabs deps
KenAJoh Oct 11, 2023
d37291f
:art: ToggleGroup context
KenAJoh Oct 11, 2023
581249c
:bug: Fikset useMonthpicker import
KenAJoh Oct 11, 2023
f1d9f8d
:fire: Fjernet shadow-dom example fra changeset config
KenAJoh Oct 12, 2023
595c2a0
:memo: Changeset
KenAJoh Oct 12, 2023
24d2668
:art: Ryddet opp i sirkulære depdendencies
KenAJoh Oct 12, 2023
07b88ed
:fire: Fjernet composeEventHandlers
KenAJoh Oct 12, 2023
4690e97
:art: Oppdatert yarn lockfile
KenAJoh Oct 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["shadow-dom", "aksel.nav.no", "aksel-icons-figma-plugin"],
"ignore": ["aksel.nav.no", "aksel-icons-figma-plugin"],

"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"updateInternalDependents": "always"
Expand Down
5 changes: 5 additions & 0 deletions .changeset/silver-rice-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---

Chores: Ryddet opp i sirkulære depdendencies
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
"react/prop-types": "off",
"react/display-name": "off",
"import/no-named-as-default": "off",
// "import/no-cycle": [1],
},
reportUnusedDisableDirectives: true,
overrides: [
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import React, { forwardRef, useContext } from "react";
import { BodyLong } from "../typography/BodyLong";
import { BodyLong } from "../typography";
import { AccordionItemContext } from "./AccordionItem";

export interface AccordionContentProps
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/accordion/AccordionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import React, { forwardRef, useContext } from "react";
import { Heading } from "../typography/Heading";
import { Heading } from "../typography";
import { AccordionContext } from "./AccordionContext";
import { AccordionItemContext } from "./AccordionItem";
import { ChevronDownIcon } from "@navikt/aksel-icons";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@navikt/aksel-icons";
import cl from "clsx";
import React, { forwardRef } from "react";
import { BodyLong } from "../typography/BodyLong";
import { BodyLong } from "../typography";
import { Button } from "../button";

export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
Expand Down
12 changes: 9 additions & 3 deletions @navikt/core/react/src/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import React, { useRef, useState, forwardRef, useMemo } from "react";
import cl from "clsx";
import { OverridableComponent, Loader, mergeRefs, Label } from "../";
import { omit, useClientLayoutEffect } from "../util";
import React, { forwardRef, useMemo, useRef, useState } from "react";
import { Loader } from "../loader";
import { Label } from "../typography";
import {
mergeRefs,
OverridableComponent,
omit,
useClientLayoutEffect,
} from "../util";

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/chips/Chips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import React, { forwardRef, HTMLAttributes } from "react";
import ToggleChips, { ToggleChipsProps } from "./Toggle";
import RemovableChips, { RemovableChipsProps } from "./Removable";
import { OverridableComponent } from "../util/OverridableComponent";
import { OverridableComponent } from "../util";

export interface ChipsProps extends HTMLAttributes<HTMLUListElement> {
children: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/chips/Toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import React, { forwardRef } from "react";
import { OverridableComponent } from "../util/OverridableComponent";
import { OverridableComponent } from "../util";

export interface ToggleChipsProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/copybutton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
useState,
} from "react";
import copy from "../util/copy";
import Label from "../typography/Label";
import { Label } from "../typography";

export interface CopyButtonProps
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
Expand Down
3 changes: 2 additions & 1 deletion @navikt/core/react/src/date/DateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { CalendarIcon } from "@navikt/aksel-icons";
import cl from "clsx";
import React, { forwardRef, InputHTMLAttributes } from "react";
import { BodyShort, ErrorMessage, Label, omit } from "..";
import { FormFieldProps, useFormField } from "../form/useFormField";
import { useDateInputContext } from "./context";
import { ReadOnlyIcon } from "../form/ReadOnlyIcon";
import { BodyShort, ErrorMessage, Label } from "../typography";
import { omit } from "../util";

export interface DateInputProps
extends FormFieldProps,
Expand Down
132 changes: 8 additions & 124 deletions @navikt/core/react/src/date/datepicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,135 +1,21 @@
import cl from "clsx";
import isWeekend from "date-fns/isWeekend";
import React, { forwardRef, useRef, useState } from "react";
import {
DateRange,
DayPicker,
DayPickerBase,
Matcher,
isMatch,
} from "react-day-picker";
import { Popover, omit, useId } from "../..";
import { DateInputProps, DatePickerInput } from "../DateInput";
import { DateRange, DayPicker, isMatch } from "react-day-picker";
import { Popover } from "../../popover";
import { omit, useId } from "../../util";
import { DatePickerInput } from "../DateInput";
import { DateContext } from "../context";
import { getLocaleFromString, labels } from "../utils";
import DatePickerStandalone, {
DatePickerStandaloneType,
} from "./DatePickerStandalone";
import DatePickerStandalone from "./DatePickerStandalone";
import Caption from "./parts/Caption";
import DayButton from "./parts/DayButton";
import DropdownCaption from "./parts/DropdownCaption";
import { HeadRow } from "./parts/HeadRow";
import Row from "./parts/Row";
import TableHead from "./parts/TableHead";
import WeekNumber from "./parts/WeekNumber";

export type SingleMode = {
mode?: "single";
onSelect?: (val?: Date) => void;
selected?: Date;
defaultSelected?: Date;
onWeekNumberClick?: never;
};

export type MultipleMode = {
mode: "multiple";
onSelect?: (val?: Date[]) => void;
selected?: Date[];
defaultSelected?: Date[];
min?: number;
max?: number;
/**
* Allows selecting a week at a time. Only used with mode="multiple".
*/
onWeekNumberClick?: DayPickerBase["onWeekNumberClick"];
};

export type RangeMode = {
mode: "range";
onSelect?: (val?: DateRange) => void;
selected?: DateRange;
defaultSelected?: DateRange;
min?: number;
max?: number;
onWeekNumberClick?: never;
};

type ConditionalModeProps = SingleMode | MultipleMode | RangeMode;

//github.com/gpbl/react-day-picker/blob/50b6dba/packages/react-day-picker/src/types/DayPickerBase.ts#L139
export interface DatePickerDefaultProps
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect">,
Pick<DayPickerBase, "month" | "onMonthChange" | "today" | "onDayClick"> {
/**
* Element datepicker anchors to. Use <DatePicker.Input /> for built-in toggle, or make your own with the open/onClose props
*/
children?: React.ReactNode;
/**
* Classname for datepicker in popover
*/
className?: string;
/**
* Classname for wrapper
*/
wrapperClassName?: string;
/**
* Changes datepicker locale
* @default "nb" (norsk bokmål)
*/
locale?: "nb" | "nn" | "en";
/**
* The earliest day to start navigation.
*/
fromDate?: Date;
/**
* The latests day to end navigation.
*/
toDate?: Date;
/**
* Display dropdown for choosing the month and the year. Needs `fromDate` + `toDate` to work.
* @default false
*/
dropdownCaption?: boolean;
/**
* Apply the disabled modifier to the matching days.
* https://react-day-picker.js.org/api/types/Matcher
*/
disabled?: Matcher[];
/**
* Disable saturday and sunday.
* @default false
*/
disableWeekends?: boolean;
/**
* Shows week numbers in left-column. Use with caution, takes up valuable screenspace for small screens.
* @default false
*/
showWeekNumber?: boolean;
/**
* Open state for user-controlled state. Component controlled by default
*/
open?: boolean;
/**
* onClose callback for user-controlled state
*/
onClose?: () => void;
/**
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used
*/
onOpenToggle?: () => void;
/**
* Avoid using if possible!
* Changes what CSS position property to use.
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
* @default See Popover
*/
strategy?: "absolute" | "fixed";
/**
* Bubbles Escape keydown-event up trough DOM-tree. This is set to false by default to prevent closing components like Modal on Escape
* @default false
*/
bubbleEscape?: boolean;
}
import { ConditionalModeProps, DatePickerDefaultProps } from "./types";

export type DatePickerProps = DatePickerDefaultProps & ConditionalModeProps;

Expand All @@ -145,14 +31,12 @@ interface DatePickerComponent
* />
* ```
*/
Standalone: DatePickerStandaloneType;
Standalone: typeof DatePickerStandalone;
/**
* Custom TextField for DatePicker
* @see 🏷️ {@link DateInputProps}
*/
Input: React.ForwardRefExoticComponent<
DateInputProps & React.RefAttributes<HTMLInputElement>
>;
Input: typeof DatePickerInput;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions @navikt/core/react/src/date/datepicker/DatePickerStandalone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import cl from "clsx";
import isWeekend from "date-fns/isWeekend";
import React, { forwardRef } from "react";
import { DateRange, DayPicker, isMatch } from "react-day-picker";
import { omit } from "../..";
import { omit } from "../../util";
import { getLocaleFromString, labels } from "../utils";
import Caption from "./parts/Caption";
import DayButton from "./parts/DayButton";
import DropdownCaption from "./parts/DropdownCaption";
import { HeadRow } from "./parts/HeadRow";
import Row from "./parts/Row";
import TableHead from "./parts/TableHead";
import WeekNumber from "./parts/WeekNumber";
import {
DatePickerDefaultProps,
MultipleMode,
RangeMode,
SingleMode,
} from "./DatePicker";
import TableHead from "./parts/TableHead";
import WeekNumber from "./parts/WeekNumber";
import Caption from "./parts/Caption";
import DropdownCaption from "./parts/DropdownCaption";
import Row from "./parts/Row";
import { HeadRow } from "./parts/HeadRow";
import DayButton from "./parts/DayButton";
} from "./types";

interface DatePickerStandaloneDefaultProps
extends Omit<
Expand Down
4 changes: 3 additions & 1 deletion @navikt/core/react/src/date/datepicker/parts/Caption.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
import React from "react";
import { CaptionProps, useDayPicker, useNavigation } from "react-day-picker";
import { Button, Label } from "../../..";

import WeekRow from "./WeekRow";
import { Button } from "../../../button";
import { Label } from "../../../typography";

/**
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Caption
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
import { max, min } from "date-fns";
import setMonth from "date-fns/setMonth";
import setYear from "date-fns/setYear";
import startOfMonth from "date-fns/startOfMonth";
import React from "react";
import { CaptionProps, useDayPicker, useNavigation } from "react-day-picker";
import { Button, Select } from "../../..";
import { Button } from "../../../button";
import { Select } from "../../../form/Select";
import { getMonths, getYears } from "../../utils/get-dates";
import { labelMonthDropdown, labelYearDropdown } from "../../utils/labels";
import { max, min } from "date-fns";
import WeekRow from "./WeekRow";

/**
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/datepicker/parts/WeekRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from "react";
import { useDayPicker } from "react-day-picker";
import { Show } from "../../../layout/responsive";
import { Detail } from "../../../typography";
import { useId } from "../../../util";
import { getMonthWeeks } from "../../utils/get-month-weeks";
import { labelWeek } from "../../utils/labels";
import WeekNumber from "./WeekNumber";
import { useId } from "../../../util";

const WeekRow = ({ displayMonth }: { displayMonth: Date }) => {
const { locale, fixedWeeks, onWeekNumberClick } = useDayPicker();
Expand Down
Loading