@ndla/primitives 0.0.2 → 0.0.4
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/dist/panda.buildinfo.json +95 -25
- package/dist/styles.css +340 -50
- package/es/ArticleLists.js +4 -32
- package/es/Badge.js +4 -16
- package/es/BlockQuote.js +5 -17
- package/es/Button.js +40 -33
- package/es/Checkbox.js +160 -51
- package/es/Dialog.js +6 -7
- package/es/ExpandableBox.js +4 -17
- package/es/Field.js +17 -0
- package/es/FieldErrorMessage.js +12 -16
- package/es/FieldHelper.js +9 -12
- package/es/FramedContent.js +3 -15
- package/es/Icon.js +9 -6
- package/es/Input.js +25 -23
- package/es/Label.js +15 -39
- package/es/Menu.js +32 -6
- package/es/MessageBox.js +3 -15
- package/es/NdlaLogo.js +6 -5
- package/es/RadioGroup.js +7 -11
- package/es/Skeleton.js +2 -8
- package/es/Spinner.js +3 -15
- package/es/Switch.js +8 -15
- package/es/Table.js +2 -5
- package/es/Tabs.js +231 -0
- package/es/Text.js +33 -32
- package/es/Toast.js +14 -6
- package/es/createStyleContext.js +15 -7
- package/lib/Accordion.d.ts +14 -7
- package/lib/ArticleLists.d.ts +9 -11
- package/lib/ArticleLists.js +5 -36
- package/lib/Badge.d.ts +9 -4
- package/lib/Badge.js +4 -17
- package/lib/BlockQuote.d.ts +9 -3
- package/lib/BlockQuote.js +5 -18
- package/lib/Button.d.ts +24 -11
- package/lib/Button.js +39 -32
- package/lib/Checkbox.d.ts +172 -5
- package/lib/Checkbox.js +165 -56
- package/lib/Dialog.d.ts +18 -10
- package/lib/Dialog.js +6 -7
- package/lib/ExpandableBox.d.ts +8 -5
- package/lib/ExpandableBox.js +5 -20
- package/lib/Field.d.ts +9 -0
- package/lib/Field.js +23 -0
- package/lib/FieldErrorMessage.d.ts +3 -3
- package/lib/FieldErrorMessage.js +11 -15
- package/lib/FieldHelper.d.ts +3 -3
- package/lib/FieldHelper.js +8 -11
- package/lib/FramedContent.d.ts +8 -4
- package/lib/FramedContent.js +3 -16
- package/lib/Icon.d.ts +3 -2
- package/lib/Icon.js +8 -5
- package/lib/Input.d.ts +12 -11
- package/lib/Input.js +25 -23
- package/lib/Label.d.ts +13 -7
- package/lib/Label.js +15 -39
- package/lib/Menu.d.ts +66 -13
- package/lib/Menu.js +41 -15
- package/lib/MessageBox.d.ts +8 -4
- package/lib/MessageBox.js +3 -16
- package/lib/NdlaLogo.d.ts +5 -4
- package/lib/NdlaLogo.js +5 -4
- package/lib/Pagination.d.ts +17 -6
- package/lib/Popover.d.ts +34 -13
- package/lib/RadioGroup.d.ts +18 -7
- package/lib/RadioGroup.js +7 -11
- package/lib/Skeleton.d.ts +5 -2
- package/lib/Skeleton.js +3 -10
- package/lib/Slider.d.ts +18 -7
- package/lib/Spinner.d.ts +8 -3
- package/lib/Spinner.js +3 -16
- package/lib/Switch.d.ts +12 -7
- package/lib/Switch.js +13 -20
- package/lib/Table.d.ts +6 -3
- package/lib/Table.js +4 -8
- package/lib/Tabs.d.ts +145 -0
- package/lib/Tabs.js +239 -0
- package/lib/Text.d.ts +6 -9
- package/lib/Text.js +32 -33
- package/lib/Toast.d.ts +10 -7
- package/lib/Toast.js +15 -7
- package/lib/Tooltip.d.ts +19 -7
- package/lib/createStyleContext.d.ts +5 -3
- package/lib/createStyleContext.js +14 -6
- package/package.json +5 -5
- package/es/FormControl.js +0 -163
- package/lib/FormControl.d.ts +0 -65
- package/lib/FormControl.js +0 -173
package/lib/Spinner.d.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { HTMLArkProps } from "@ark-ui/react";
|
|
9
9
|
import { RecipeVariantProps } from "@ndla/styled-system/css";
|
|
10
|
+
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
10
11
|
export declare const spinnerRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
11
12
|
size: {
|
|
12
13
|
medium: {
|
|
@@ -22,5 +23,9 @@ export declare const spinnerRecipe: import("@ndla/styled-system/types").RecipeRu
|
|
|
22
23
|
};
|
|
23
24
|
}>;
|
|
24
25
|
export type SpinnerVariantProps = RecipeVariantProps<typeof spinnerRecipe>;
|
|
25
|
-
export type SpinnerProps =
|
|
26
|
-
export declare const Spinner:
|
|
26
|
+
export type SpinnerProps = HTMLArkProps<"div"> & SpinnerVariantProps & JsxStyleProps;
|
|
27
|
+
export declare const Spinner: import("@ndla/styled-system/jsx").StyledComponent<import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
28
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
29
|
+
} & import("@ark-ui/react").PolymorphicProps>, {
|
|
30
|
+
size?: "medium" | "large" | undefined;
|
|
31
|
+
}>;
|
package/lib/Spinner.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.spinnerRecipe = exports.Spinner = void 0;
|
|
7
|
+
var _react = require("@ark-ui/react");
|
|
7
8
|
var _css = require("@ndla/styled-system/css");
|
|
8
|
-
var
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
var _jsx = require("@ndla/styled-system/jsx");
|
|
10
10
|
/**
|
|
11
11
|
* Copyright (c) 2024-present, NDLA.
|
|
12
12
|
*
|
|
@@ -45,17 +45,4 @@ const spinnerRecipe = exports.spinnerRecipe = (0, _css.cva)({
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
const Spinner =
|
|
49
|
-
let {
|
|
50
|
-
size,
|
|
51
|
-
className,
|
|
52
|
-
...props
|
|
53
|
-
} = _ref;
|
|
54
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsx2.styled.div, {
|
|
55
|
-
className: (0, _css.cx)(spinnerRecipe({
|
|
56
|
-
size
|
|
57
|
-
}), className),
|
|
58
|
-
...props
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
exports.Spinner = Spinner;
|
|
48
|
+
const Spinner = exports.Spinner = (0, _jsx.styled)(_react.ark.div, spinnerRecipe);
|
package/lib/Switch.d.ts
CHANGED
|
@@ -7,15 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Switch } from "@ark-ui/react";
|
|
9
9
|
import { RecipeVariantProps } from "@ndla/styled-system/css";
|
|
10
|
+
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
10
11
|
import { TextProps } from "./Text";
|
|
11
12
|
declare const switchRecipe: import("@ndla/styled-system/types").SlotRecipeRuntimeFn<"label" | "root" | "control" | "thumb", import("@ndla/styled-system/types").SlotRecipeVariantRecord<"label" | "root" | "control" | "thumb">>;
|
|
12
13
|
export type SwitchVariantProps = RecipeVariantProps<typeof switchRecipe>;
|
|
13
|
-
export type SwitchRootProps = Switch.RootProps & SwitchVariantProps;
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
export type SwitchRootProps = Switch.RootProps & JsxStyleProps & SwitchVariantProps;
|
|
15
|
+
export declare const SwitchRoot: import("react").ForwardRefExoticComponent<Switch.RootProps & {
|
|
16
|
+
forwardCssProp?: boolean | undefined;
|
|
17
|
+
} & import("@ndla/styled-system/types").WithCss & {} & import("react").RefAttributes<HTMLLabelElement>>;
|
|
18
|
+
export declare const SwitchControl: import("react").ForwardRefExoticComponent<{
|
|
19
|
+
forwardCssProp?: boolean | undefined;
|
|
20
|
+
} & import("@ndla/styled-system/types").WithCss & Switch.ControlProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
21
|
+
export declare const SwitchThumb: import("react").ForwardRefExoticComponent<{
|
|
22
|
+
forwardCssProp?: boolean | undefined;
|
|
23
|
+
} & import("@ndla/styled-system/types").WithCss & Switch.ThumbProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
24
|
+
export declare const SwitchLabel: ({ textStyle, children, ...props }: Switch.LabelProps & TextProps & JsxStyleProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
25
|
export declare const SwitchHiddenInput: import("react").ForwardRefExoticComponent<Switch.HiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
21
26
|
export {};
|
package/lib/Switch.js
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SwitchThumb = exports.SwitchRoot = exports.SwitchLabel = exports.SwitchHiddenInput = exports.SwitchControl =
|
|
7
|
-
var _react = require("react");
|
|
6
|
+
exports.SwitchThumb = exports.SwitchRoot = exports.SwitchLabel = exports.SwitchHiddenInput = exports.SwitchControl = void 0;
|
|
8
7
|
var _anatomy = require("@ark-ui/anatomy");
|
|
9
|
-
var
|
|
8
|
+
var _react = require("@ark-ui/react");
|
|
10
9
|
var _css = require("@ndla/styled-system/css");
|
|
11
10
|
var _createStyleContext = require("./createStyleContext");
|
|
12
|
-
var _FormControl = require("./FormControl");
|
|
13
11
|
var _Text = require("./Text");
|
|
14
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
13
|
/**
|
|
@@ -106,32 +104,27 @@ const {
|
|
|
106
104
|
withProvider,
|
|
107
105
|
withContext
|
|
108
106
|
} = (0, _createStyleContext.createStyleContext)(switchRecipe);
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalSwitchRoot, {
|
|
114
|
-
invalid: (_field$invalid = field.invalid) !== null && _field$invalid !== void 0 ? _field$invalid : !!field["aria-invalid"],
|
|
115
|
-
...field,
|
|
116
|
-
ref: ref
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
const SwitchControl = exports.SwitchControl = withContext(_react2.Switch.Control, "control");
|
|
120
|
-
const SwitchThumb = exports.SwitchThumb = withContext(_react2.Switch.Thumb, "thumb");
|
|
121
|
-
const InternalSwitchLabel = exports.InternalSwitchLabel = withContext(_react2.Switch.Label, "label");
|
|
107
|
+
const SwitchRoot = exports.SwitchRoot = withProvider(_react.Switch.Root, "root");
|
|
108
|
+
const SwitchControl = exports.SwitchControl = withContext(_react.Switch.Control, "control");
|
|
109
|
+
const SwitchThumb = exports.SwitchThumb = withContext(_react.Switch.Thumb, "thumb");
|
|
110
|
+
const InternalSwitchLabel = withContext(_react.Switch.Label, "label");
|
|
122
111
|
const SwitchLabel = _ref => {
|
|
123
112
|
let {
|
|
124
113
|
textStyle = "label.medium",
|
|
114
|
+
children,
|
|
125
115
|
...props
|
|
126
116
|
} = _ref;
|
|
127
117
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalSwitchLabel, {
|
|
128
118
|
asChild: true,
|
|
129
119
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
130
|
-
|
|
120
|
+
asChild: true,
|
|
131
121
|
textStyle: textStyle,
|
|
132
|
-
...props
|
|
122
|
+
...props,
|
|
123
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
124
|
+
children: children
|
|
125
|
+
})
|
|
133
126
|
})
|
|
134
127
|
});
|
|
135
128
|
};
|
|
136
129
|
exports.SwitchLabel = SwitchLabel;
|
|
137
|
-
const SwitchHiddenInput = exports.SwitchHiddenInput =
|
|
130
|
+
const SwitchHiddenInput = exports.SwitchHiddenInput = _react.Switch.HiddenInput;
|
package/lib/Table.d.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export
|
|
8
|
+
import { HTMLArkProps } from "@ark-ui/react";
|
|
9
|
+
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
10
|
+
export type TableProps = HTMLArkProps<"table"> & JsxStyleProps;
|
|
11
|
+
export declare const Table: import("@ndla/styled-system/jsx").StyledComponent<import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & {
|
|
12
|
+
ref?: ((instance: HTMLTableElement | null) => void) | import("react").RefObject<HTMLTableElement> | null | undefined;
|
|
13
|
+
} & import("@ark-ui/react").PolymorphicProps>, {}>;
|
package/lib/Table.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Table = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var _react = require("@ark-ui/react");
|
|
8
|
+
var _jsx = require("@ndla/styled-system/jsx");
|
|
9
9
|
/**
|
|
10
10
|
* Copyright (c) 2024-present, NDLA.
|
|
11
11
|
*
|
|
@@ -14,7 +14,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const Table = exports.Table = (0, _jsx.styled)(_react.ark.table, {
|
|
18
18
|
base: {
|
|
19
19
|
display: "block",
|
|
20
20
|
overflowX: "auto",
|
|
@@ -75,8 +75,4 @@ const StyledTable = (0, _jsx2.styled)("table", {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
});
|
|
79
|
-
const Table = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledTable, {
|
|
80
|
-
...props
|
|
81
|
-
});
|
|
82
|
-
exports.Table = Table;
|
|
78
|
+
});
|
package/lib/Tabs.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { Tabs } from "@ark-ui/react";
|
|
9
|
+
import { RecipeVariantProps } from "@ndla/styled-system/css";
|
|
10
|
+
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
11
|
+
declare const tabsRecipe: import("@ndla/styled-system/types").SlotRecipeRuntimeFn<"content" | "list" | "root" | "indicator" | "trigger", {
|
|
12
|
+
variant: {
|
|
13
|
+
line: {
|
|
14
|
+
trigger: {
|
|
15
|
+
borderColor: "stroke.default";
|
|
16
|
+
_hover: {
|
|
17
|
+
borderColor: "stroke.hover";
|
|
18
|
+
_focusVisible: {
|
|
19
|
+
borderColor: "stroke.default";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
_horizontal: {
|
|
23
|
+
borderBottom: "1px solid";
|
|
24
|
+
};
|
|
25
|
+
_disabled: {
|
|
26
|
+
borderColor: "stroke.default";
|
|
27
|
+
_hover: {
|
|
28
|
+
borderColor: "stroke.default";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
_vertical: {
|
|
32
|
+
borderLeft: "1px solid";
|
|
33
|
+
justifyContent: "flex-start";
|
|
34
|
+
};
|
|
35
|
+
_focusVisible: {
|
|
36
|
+
outline: "none";
|
|
37
|
+
borderRadius: "unset";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
indicator: {
|
|
41
|
+
background: "transparent";
|
|
42
|
+
outline: "4px solid";
|
|
43
|
+
outlineColor: "stroke.default";
|
|
44
|
+
pointerEvents: "none";
|
|
45
|
+
outlineOffset: "-4px";
|
|
46
|
+
_peerFocusVisible: {
|
|
47
|
+
height: "var(--height)";
|
|
48
|
+
width: "var(--width)";
|
|
49
|
+
_horizontal: {
|
|
50
|
+
borderTopRadius: "xsmall";
|
|
51
|
+
};
|
|
52
|
+
_vertical: {
|
|
53
|
+
borderRightRadius: "xsmall";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
_horizontal: {
|
|
57
|
+
bottom: "0";
|
|
58
|
+
height: "2";
|
|
59
|
+
width: "var(--width)";
|
|
60
|
+
};
|
|
61
|
+
_vertical: {
|
|
62
|
+
height: "var(--height)";
|
|
63
|
+
left: "0";
|
|
64
|
+
width: "2";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
content: {
|
|
68
|
+
zIndex: "1";
|
|
69
|
+
_horizontal: {
|
|
70
|
+
paddingBlockStart: "xsmall";
|
|
71
|
+
};
|
|
72
|
+
_vertical: {
|
|
73
|
+
paddingInlineStart: "xsmall";
|
|
74
|
+
};
|
|
75
|
+
_focusVisible: {
|
|
76
|
+
outline: "none";
|
|
77
|
+
boxShadow: "0 0 0 3px var(--shadow-color)";
|
|
78
|
+
boxShadowColor: "stroke.default";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
outline: {
|
|
83
|
+
list: {
|
|
84
|
+
_horizontal: {
|
|
85
|
+
marginBlockEnd: "-1px";
|
|
86
|
+
};
|
|
87
|
+
_vertical: {
|
|
88
|
+
marginInlineEnd: "-1px";
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
trigger: {
|
|
92
|
+
borderColor: "transparent";
|
|
93
|
+
borderWidth: "1px";
|
|
94
|
+
_horizontal: {
|
|
95
|
+
borderTopRadius: "xsmall";
|
|
96
|
+
};
|
|
97
|
+
_vertical: {
|
|
98
|
+
borderTopLeftRadius: "xsmall";
|
|
99
|
+
borderBottomLeftRadius: "xsmall";
|
|
100
|
+
};
|
|
101
|
+
_selected: {
|
|
102
|
+
background: "surface.default";
|
|
103
|
+
borderColor: "stroke.subtle";
|
|
104
|
+
_horizontal: {
|
|
105
|
+
borderBottomColor: "transparent";
|
|
106
|
+
};
|
|
107
|
+
_vertical: {
|
|
108
|
+
borderRightColor: "transparent";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
_focusVisible: {
|
|
112
|
+
outline: "3px solid";
|
|
113
|
+
outlineOffset: "-3px";
|
|
114
|
+
outlineColor: "stroke.default";
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
content: {
|
|
118
|
+
borderWidth: "1px";
|
|
119
|
+
borderColor: "stroke.subtle";
|
|
120
|
+
background: "surface.default";
|
|
121
|
+
width: "100%";
|
|
122
|
+
padding: "xsmall";
|
|
123
|
+
_focusVisible: {
|
|
124
|
+
outline: "3px solid";
|
|
125
|
+
outlineOffset: "-3px";
|
|
126
|
+
outlineColor: "stroke.default";
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
}>;
|
|
132
|
+
export type TabsVariantProps = RecipeVariantProps<typeof tabsRecipe>;
|
|
133
|
+
export type TabsRootProps = Tabs.RootProps & TabsVariantProps & JsxStyleProps;
|
|
134
|
+
export declare const TabsRoot: ({ lazyMount, unmountOnExit, ...props }: TabsRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
135
|
+
export declare const TabsContent: import("react").ForwardRefExoticComponent<Tabs.ContentProps & {
|
|
136
|
+
forwardCssProp?: boolean | undefined;
|
|
137
|
+
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLDivElement>>;
|
|
138
|
+
export declare const TabsIndicator: import("react").ForwardRefExoticComponent<Tabs.IndicatorProps & {
|
|
139
|
+
forwardCssProp?: boolean | undefined;
|
|
140
|
+
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLDivElement>>;
|
|
141
|
+
export declare const TabsList: import("react").ForwardRefExoticComponent<Tabs.ListProps & {
|
|
142
|
+
forwardCssProp?: boolean | undefined;
|
|
143
|
+
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLDivElement>>;
|
|
144
|
+
export declare const TabsTrigger: ({ className, ...props }: Tabs.TriggerProps & JsxStyleProps) => import("react/jsx-runtime").JSX.Element;
|
|
145
|
+
export {};
|
package/lib/Tabs.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TabsTrigger = exports.TabsRoot = exports.TabsList = exports.TabsIndicator = exports.TabsContent = void 0;
|
|
7
|
+
var _anatomy = require("@ark-ui/anatomy");
|
|
8
|
+
var _react = require("@ark-ui/react");
|
|
9
|
+
var _css = require("@ndla/styled-system/css");
|
|
10
|
+
var _createStyleContext = require("./createStyleContext");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) 2024-present, NDLA.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const tabsRecipe = (0, _css.sva)({
|
|
21
|
+
slots: _anatomy.tabsAnatomy.keys(),
|
|
22
|
+
base: {
|
|
23
|
+
root: {
|
|
24
|
+
position: "relative",
|
|
25
|
+
display: "flex",
|
|
26
|
+
width: "100%",
|
|
27
|
+
_horizontal: {
|
|
28
|
+
flexDirection: "column"
|
|
29
|
+
},
|
|
30
|
+
_vertical: {
|
|
31
|
+
flexDirection: "row"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
list: {
|
|
35
|
+
position: "relative",
|
|
36
|
+
display: "flex",
|
|
37
|
+
flexShrink: "0",
|
|
38
|
+
overflow: "auto",
|
|
39
|
+
_horizontal: {
|
|
40
|
+
flexDirection: "row"
|
|
41
|
+
},
|
|
42
|
+
_vertical: {
|
|
43
|
+
flexDirection: "column"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
trigger: {
|
|
47
|
+
display: "inline-flex",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
flexShrink: "0",
|
|
51
|
+
cursor: "pointer",
|
|
52
|
+
textStyle: "label.small",
|
|
53
|
+
fontWeight: "bold",
|
|
54
|
+
transitionDuration: "normal",
|
|
55
|
+
transitionProperty: "color, background, border-color",
|
|
56
|
+
transitionTimingFunction: "default",
|
|
57
|
+
whiteSpace: "nowrap",
|
|
58
|
+
paddingInline: "small",
|
|
59
|
+
paddingBlock: "3xsmall",
|
|
60
|
+
zIndex: "1",
|
|
61
|
+
_hover: {
|
|
62
|
+
color: "text.action"
|
|
63
|
+
},
|
|
64
|
+
_selected: {
|
|
65
|
+
color: "text.strong"
|
|
66
|
+
},
|
|
67
|
+
_disabled: {
|
|
68
|
+
color: "text.subtle",
|
|
69
|
+
cursor: "not-allowed",
|
|
70
|
+
_hover: {
|
|
71
|
+
color: "text.subtle"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
content: {
|
|
76
|
+
display: "flex",
|
|
77
|
+
flexDirection: "column",
|
|
78
|
+
alignItems: "flex-start",
|
|
79
|
+
gap: "xsmall"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
defaultVariants: {
|
|
83
|
+
variant: "line"
|
|
84
|
+
},
|
|
85
|
+
variants: {
|
|
86
|
+
variant: {
|
|
87
|
+
line: {
|
|
88
|
+
trigger: {
|
|
89
|
+
borderColor: "stroke.default",
|
|
90
|
+
_hover: {
|
|
91
|
+
borderColor: "stroke.hover",
|
|
92
|
+
_focusVisible: {
|
|
93
|
+
borderColor: "stroke.default"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
_horizontal: {
|
|
97
|
+
borderBottom: "1px solid"
|
|
98
|
+
},
|
|
99
|
+
_disabled: {
|
|
100
|
+
borderColor: "stroke.default",
|
|
101
|
+
_hover: {
|
|
102
|
+
borderColor: "stroke.default"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
_vertical: {
|
|
106
|
+
borderLeft: "1px solid",
|
|
107
|
+
justifyContent: "flex-start"
|
|
108
|
+
},
|
|
109
|
+
_focusVisible: {
|
|
110
|
+
outline: "none",
|
|
111
|
+
borderRadius: "unset"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
indicator: {
|
|
115
|
+
background: "transparent",
|
|
116
|
+
outline: "4px solid",
|
|
117
|
+
outlineColor: "stroke.default",
|
|
118
|
+
pointerEvents: "none",
|
|
119
|
+
outlineOffset: "-4px",
|
|
120
|
+
_peerFocusVisible: {
|
|
121
|
+
height: "var(--height)",
|
|
122
|
+
width: "var(--width)",
|
|
123
|
+
_horizontal: {
|
|
124
|
+
borderTopRadius: "xsmall"
|
|
125
|
+
},
|
|
126
|
+
_vertical: {
|
|
127
|
+
borderRightRadius: "xsmall"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
_horizontal: {
|
|
131
|
+
bottom: "0",
|
|
132
|
+
height: "2",
|
|
133
|
+
width: "var(--width)"
|
|
134
|
+
},
|
|
135
|
+
_vertical: {
|
|
136
|
+
height: "var(--height)",
|
|
137
|
+
left: "0",
|
|
138
|
+
width: "2"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
content: {
|
|
142
|
+
zIndex: "1",
|
|
143
|
+
_horizontal: {
|
|
144
|
+
paddingBlockStart: "xsmall"
|
|
145
|
+
},
|
|
146
|
+
_vertical: {
|
|
147
|
+
paddingInlineStart: "xsmall"
|
|
148
|
+
},
|
|
149
|
+
_focusVisible: {
|
|
150
|
+
outline: "none",
|
|
151
|
+
boxShadow: "0 0 0 3px var(--shadow-color)",
|
|
152
|
+
boxShadowColor: "stroke.default"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
outline: {
|
|
157
|
+
list: {
|
|
158
|
+
_horizontal: {
|
|
159
|
+
marginBlockEnd: "-1px"
|
|
160
|
+
},
|
|
161
|
+
_vertical: {
|
|
162
|
+
marginInlineEnd: "-1px"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
trigger: {
|
|
166
|
+
borderColor: "transparent",
|
|
167
|
+
borderWidth: "1px",
|
|
168
|
+
_horizontal: {
|
|
169
|
+
borderTopRadius: "xsmall"
|
|
170
|
+
},
|
|
171
|
+
_vertical: {
|
|
172
|
+
borderTopLeftRadius: "xsmall",
|
|
173
|
+
borderBottomLeftRadius: "xsmall"
|
|
174
|
+
},
|
|
175
|
+
_selected: {
|
|
176
|
+
background: "surface.default",
|
|
177
|
+
borderColor: "stroke.subtle",
|
|
178
|
+
_horizontal: {
|
|
179
|
+
borderBottomColor: "transparent"
|
|
180
|
+
},
|
|
181
|
+
_vertical: {
|
|
182
|
+
borderRightColor: "transparent"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
_focusVisible: {
|
|
186
|
+
outline: "3px solid",
|
|
187
|
+
outlineOffset: "-3px",
|
|
188
|
+
outlineColor: "stroke.default"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
content: {
|
|
192
|
+
borderWidth: "1px",
|
|
193
|
+
borderColor: "stroke.subtle",
|
|
194
|
+
background: "surface.default",
|
|
195
|
+
width: "100%",
|
|
196
|
+
padding: "xsmall",
|
|
197
|
+
_focusVisible: {
|
|
198
|
+
outline: "3px solid",
|
|
199
|
+
outlineOffset: "-3px",
|
|
200
|
+
outlineColor: "stroke.default"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const {
|
|
208
|
+
withProvider,
|
|
209
|
+
withContext
|
|
210
|
+
} = (0, _createStyleContext.createStyleContext)(tabsRecipe);
|
|
211
|
+
const InternalTabsRoot = withProvider(_react.Tabs.Root, "root");
|
|
212
|
+
const TabsRoot = _ref => {
|
|
213
|
+
let {
|
|
214
|
+
lazyMount = true,
|
|
215
|
+
unmountOnExit = true,
|
|
216
|
+
...props
|
|
217
|
+
} = _ref;
|
|
218
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalTabsRoot, {
|
|
219
|
+
lazyMount: lazyMount,
|
|
220
|
+
unmountOnExit: unmountOnExit,
|
|
221
|
+
...props
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
exports.TabsRoot = TabsRoot;
|
|
225
|
+
const TabsContent = exports.TabsContent = withContext(_react.Tabs.Content, "content");
|
|
226
|
+
const TabsIndicator = exports.TabsIndicator = withContext(_react.Tabs.Indicator, "indicator");
|
|
227
|
+
const TabsList = exports.TabsList = withContext(_react.Tabs.List, "list");
|
|
228
|
+
const InternalTabsTrigger = withContext(_react.Tabs.Trigger, "trigger");
|
|
229
|
+
const TabsTrigger = _ref2 => {
|
|
230
|
+
let {
|
|
231
|
+
className,
|
|
232
|
+
...props
|
|
233
|
+
} = _ref2;
|
|
234
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalTabsTrigger, {
|
|
235
|
+
className: (0, _css.cx)("peer", className),
|
|
236
|
+
...props
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
exports.TabsTrigger = TabsTrigger;
|
package/lib/Text.d.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { ComponentPropsWithoutRef, ElementType } from "react";
|
|
9
8
|
import { ColorToken, FontWeightToken } from "@ndla/styled-system/tokens";
|
|
10
9
|
import { UtilityValues } from "@ndla/styled-system/types/prop-type";
|
|
11
10
|
export interface TextProps {
|
|
@@ -14,11 +13,9 @@ export interface TextProps {
|
|
|
14
13
|
color?: ColorToken;
|
|
15
14
|
srOnly?: boolean;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} &
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export declare const Text: <T extends TextType = "p">(props: Props<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
24
|
-
export {};
|
|
16
|
+
export declare const Text: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & {
|
|
17
|
+
forwardCssProp?: boolean | undefined;
|
|
18
|
+
} & import("@ndla/styled-system/types").WithCss & TextProps & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
19
|
+
export declare const Heading: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & {
|
|
20
|
+
forwardCssProp?: boolean | undefined;
|
|
21
|
+
} & import("@ndla/styled-system/types").WithCss & TextProps & import("react").RefAttributes<HTMLHeadingElement>>;
|