@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/BlockQuote.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BlockQuote = 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
|
*
|
|
@@ -23,8 +23,8 @@ const blockQuoteRecipe = (0, _css.cva)({
|
|
|
23
23
|
variants: {
|
|
24
24
|
variant: {
|
|
25
25
|
neutral: {
|
|
26
|
-
borderColor: "stroke.subtle"
|
|
27
|
-
|
|
26
|
+
borderColor: "stroke.subtle",
|
|
27
|
+
background: "surface.default"
|
|
28
28
|
},
|
|
29
29
|
brand1: {
|
|
30
30
|
background: "surface.brand.1.subtle",
|
|
@@ -40,17 +40,4 @@ const blockQuoteRecipe = (0, _css.cva)({
|
|
|
40
40
|
variant: "neutral"
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
const BlockQuote =
|
|
44
|
-
let {
|
|
45
|
-
className,
|
|
46
|
-
variant,
|
|
47
|
-
...rest
|
|
48
|
-
} = _ref;
|
|
49
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsx2.styled.blockquote, {
|
|
50
|
-
className: (0, _css.cx)(blockQuoteRecipe({
|
|
51
|
-
variant
|
|
52
|
-
}), className),
|
|
53
|
-
...rest
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
exports.BlockQuote = BlockQuote;
|
|
43
|
+
const BlockQuote = exports.BlockQuote = (0, _jsx.styled)(_react.ark.blockquote, blockQuoteRecipe);
|
package/lib/Button.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, RecipeVariant } from "@ndla/styled-system/types";
|
|
10
11
|
export declare const buttonBaseRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
11
12
|
variant: {
|
|
12
13
|
primary: {
|
|
@@ -118,14 +119,26 @@ export declare const buttonRecipe: import("@ndla/styled-system/types").RecipeRun
|
|
|
118
119
|
};
|
|
119
120
|
};
|
|
120
121
|
}>;
|
|
121
|
-
export type ButtonVariantProps = RecipeVariantProps<typeof buttonBaseRecipe> & RecipeVariantProps<typeof buttonRecipe>;
|
|
122
|
-
export type ButtonProps = ComponentPropsWithRef<"button"> & ButtonVariantProps & {
|
|
123
|
-
variant?: Exclude<NonNullable<ButtonVariantProps>["variant"], "clear" | "clearSubtle">;
|
|
124
|
-
};
|
|
125
|
-
export declare const Button: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
126
|
-
export type IconButtonVariantProps = RecipeVariantProps<typeof buttonBaseRecipe>;
|
|
127
|
-
export type IconButtonProps = ComponentPropsWithRef<"button"> & IconButtonVariantProps & {
|
|
128
|
-
variant?: Exclude<NonNullable<IconButtonVariantProps>["variant"], "link">;
|
|
129
|
-
};
|
|
130
|
-
export declare const IconButton: import("react").ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
131
122
|
export declare const iconButtonRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<import("@ndla/styled-system/types").RecipeVariantRecord>;
|
|
123
|
+
type Variant = RecipeVariant<typeof buttonBaseRecipe>["variant"];
|
|
124
|
+
type ButtonVariant = Exclude<Variant, "clear" | "clearSubtle">;
|
|
125
|
+
export type ButtonVariantProps = {
|
|
126
|
+
variant?: ButtonVariant;
|
|
127
|
+
} & RecipeVariantProps<typeof buttonRecipe>;
|
|
128
|
+
export type ButtonProps = HTMLArkProps<"button"> & JsxStyleProps & ButtonVariantProps;
|
|
129
|
+
export declare const Button: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & {
|
|
130
|
+
forwardCssProp?: boolean | undefined;
|
|
131
|
+
} & import("@ndla/styled-system/types").WithCss & {
|
|
132
|
+
variant?: ButtonVariant | undefined;
|
|
133
|
+
} & {
|
|
134
|
+
size?: "small" | "default" | undefined;
|
|
135
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
136
|
+
type IconButtonVariant = Exclude<Variant, "link">;
|
|
137
|
+
export type IconButtonVariantProps = {
|
|
138
|
+
variant?: IconButtonVariant;
|
|
139
|
+
};
|
|
140
|
+
export type IconButtonProps = HTMLArkProps<"button"> & IconButtonVariantProps & JsxStyleProps;
|
|
141
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & IconButtonVariantProps & {
|
|
142
|
+
forwardCssProp?: boolean | undefined;
|
|
143
|
+
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLButtonElement>>;
|
|
144
|
+
export {};
|
package/lib/Button.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.iconButtonRecipe = exports.buttonRecipe = exports.buttonBaseRecipe = exports.IconButton = exports.Button = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _react2 = require("@ark-ui/react");
|
|
8
9
|
var _css = require("@ndla/styled-system/css");
|
|
9
10
|
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -166,53 +167,59 @@ const buttonRecipe = exports.buttonRecipe = (0, _css.cva)({
|
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
});
|
|
170
|
+
const iconButtonRecipe = exports.iconButtonRecipe = (0, _css.cva)({
|
|
171
|
+
base: {
|
|
172
|
+
lineHeight: "1",
|
|
173
|
+
minHeight: "unset",
|
|
174
|
+
height: "fit-content",
|
|
175
|
+
"& svg": {
|
|
176
|
+
marginInline: "0",
|
|
177
|
+
marginBlock: "0",
|
|
178
|
+
width: "medium",
|
|
179
|
+
height: "medium"
|
|
180
|
+
},
|
|
181
|
+
paddingInline: "xsmall",
|
|
182
|
+
paddingBlock: "xsmall"
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const StyledButton = (0, _jsx2.styled)(_react2.ark.button, {}, {
|
|
186
|
+
defaultProps: {
|
|
187
|
+
type: "button"
|
|
188
|
+
}
|
|
189
|
+
});
|
|
169
190
|
const Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
170
191
|
let {
|
|
171
|
-
type,
|
|
172
|
-
size,
|
|
173
|
-
className,
|
|
174
192
|
variant,
|
|
175
|
-
|
|
193
|
+
size,
|
|
194
|
+
css: cssProp,
|
|
195
|
+
...props
|
|
176
196
|
} = _ref;
|
|
177
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledButton, {
|
|
198
|
+
...props,
|
|
199
|
+
css: _css.css.raw(buttonBaseRecipe.raw({
|
|
180
200
|
variant
|
|
181
201
|
}), buttonRecipe.raw({
|
|
182
202
|
size
|
|
183
|
-
})
|
|
184
|
-
...rest,
|
|
203
|
+
}), cssProp),
|
|
185
204
|
ref: ref
|
|
186
205
|
});
|
|
187
206
|
});
|
|
207
|
+
const StyledIconButton = (0, _jsx2.styled)(_react2.ark.button, {}, {
|
|
208
|
+
defaultProps: {
|
|
209
|
+
type: "button"
|
|
210
|
+
}
|
|
211
|
+
});
|
|
188
212
|
const IconButton = exports.IconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
189
213
|
let {
|
|
190
|
-
type,
|
|
191
|
-
className,
|
|
192
214
|
variant,
|
|
193
|
-
|
|
215
|
+
css: cssProp,
|
|
216
|
+
...props
|
|
194
217
|
} = _ref2;
|
|
195
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
196
|
-
|
|
197
|
-
|
|
218
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledIconButton, {
|
|
219
|
+
...props,
|
|
220
|
+
css: _css.css.raw(buttonBaseRecipe.raw({
|
|
198
221
|
variant
|
|
199
|
-
}), iconButtonRecipe.raw()
|
|
200
|
-
...rest,
|
|
222
|
+
}), iconButtonRecipe.raw(), cssProp),
|
|
201
223
|
ref: ref
|
|
202
224
|
});
|
|
203
|
-
});
|
|
204
|
-
const iconButtonRecipe = exports.iconButtonRecipe = (0, _css.cva)({
|
|
205
|
-
base: {
|
|
206
|
-
lineHeight: "1",
|
|
207
|
-
minHeight: "unset",
|
|
208
|
-
height: "fit-content",
|
|
209
|
-
"& svg": {
|
|
210
|
-
marginInline: "0",
|
|
211
|
-
marginBlock: "0",
|
|
212
|
-
width: "medium",
|
|
213
|
-
height: "medium"
|
|
214
|
-
},
|
|
215
|
-
paddingInline: "xsmall",
|
|
216
|
-
paddingBlock: "xsmall"
|
|
217
|
-
}
|
|
218
225
|
});
|
package/lib/Checkbox.d.ts
CHANGED
|
@@ -6,10 +6,177 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import { Checkbox } from "@ark-ui/react";
|
|
9
|
+
import { JsxStyleProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
9
10
|
import { TextProps } from "./Text";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
declare const checkboxRecipe: import("@ndla/styled-system/types").SlotRecipeRuntimeFn<"label" | "group" | "root" | "indicator" | "control", {
|
|
12
|
+
variant: {
|
|
13
|
+
checkbox: {
|
|
14
|
+
root: {
|
|
15
|
+
gap: "xxsmall";
|
|
16
|
+
_hover: {
|
|
17
|
+
color: "text.action";
|
|
18
|
+
};
|
|
19
|
+
_focus: {
|
|
20
|
+
outline: "2px solid";
|
|
21
|
+
outlineOffset: "4xsmall";
|
|
22
|
+
outlineColor: "stroke.default";
|
|
23
|
+
borderRadius: "xsmall";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
control: {
|
|
27
|
+
border: "2px solid";
|
|
28
|
+
borderColor: "stroke.subtle";
|
|
29
|
+
borderRadius: "xsmall";
|
|
30
|
+
background: "surface.default";
|
|
31
|
+
_hover: {
|
|
32
|
+
boxShadow: "0 0 0 4px var(--shadow-color)";
|
|
33
|
+
boxShadowColor: "surface.actionSubtle.hover.strong";
|
|
34
|
+
};
|
|
35
|
+
_checked: {
|
|
36
|
+
backgroundColor: "surface.action";
|
|
37
|
+
borderColor: "surface.action";
|
|
38
|
+
color: "icon.onAction";
|
|
39
|
+
};
|
|
40
|
+
_disabled: {
|
|
41
|
+
borderColor: "stroke.disabled";
|
|
42
|
+
_hover: {
|
|
43
|
+
borderColor: "stroke.disabled";
|
|
44
|
+
boxShadow: "none";
|
|
45
|
+
};
|
|
46
|
+
_checked: {
|
|
47
|
+
background: "surface.disabled";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
_invalid: {
|
|
51
|
+
borderColor: "stroke.error";
|
|
52
|
+
_checked: {
|
|
53
|
+
color: "stroke.error";
|
|
54
|
+
borderColor: "stroke.error";
|
|
55
|
+
backgroundColor: "surface.default";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
chip: {
|
|
61
|
+
root: {
|
|
62
|
+
width: "fit-content";
|
|
63
|
+
color: "text.default";
|
|
64
|
+
gap: "4xsmall";
|
|
65
|
+
background: "surface.actionSubtle";
|
|
66
|
+
border: "1px solid";
|
|
67
|
+
borderColor: "stroke.subtle";
|
|
68
|
+
outlineColor: "stroke.subtle";
|
|
69
|
+
paddingInline: "xsmall";
|
|
70
|
+
paddingBlock: "4xsmall";
|
|
71
|
+
borderRadius: "large";
|
|
72
|
+
minHeight: "large";
|
|
73
|
+
transitionDuration: "normal";
|
|
74
|
+
transitionProperty: "border-color, background, box-shadow, color";
|
|
75
|
+
transitionTimingFunction: "default";
|
|
76
|
+
_disabled: {
|
|
77
|
+
color: "text.disabled";
|
|
78
|
+
borderColor: "stroke.disabled";
|
|
79
|
+
background: "surface.disabled";
|
|
80
|
+
_hover: {
|
|
81
|
+
color: "text.disabled";
|
|
82
|
+
borderColor: "stroke.disabled";
|
|
83
|
+
background: "surface.disabled";
|
|
84
|
+
};
|
|
85
|
+
_checked: {
|
|
86
|
+
color: "text.disabled";
|
|
87
|
+
borderColor: "stroke.disabled";
|
|
88
|
+
background: "surface.disabled";
|
|
89
|
+
_hover: {
|
|
90
|
+
color: "text.disabled";
|
|
91
|
+
borderColor: "stroke.disabled";
|
|
92
|
+
background: "surface.disabled";
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
_hover: {
|
|
97
|
+
background: "surface.actionSubtle.hover";
|
|
98
|
+
borderColor: "stroke.hover";
|
|
99
|
+
outlineColor: "stroke.hover";
|
|
100
|
+
_invalid: {
|
|
101
|
+
backgroundColor: "surface.dangerSubtle";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
_checked: {
|
|
105
|
+
color: "text.onAction";
|
|
106
|
+
background: "surface.actionSubtle.selected";
|
|
107
|
+
borderColor: "surface.actionSubtle.selected";
|
|
108
|
+
outlineColor: "icon.onAction";
|
|
109
|
+
_focus: {
|
|
110
|
+
outlineOffset: "-4px";
|
|
111
|
+
};
|
|
112
|
+
_hover: {
|
|
113
|
+
outlineOffset: "-2px";
|
|
114
|
+
background: "surface.actionSubtle.hover";
|
|
115
|
+
color: "text.default";
|
|
116
|
+
borderColor: "stroke.hover";
|
|
117
|
+
outlineColor: "stroke.hover";
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
_invalid: {
|
|
121
|
+
borderColor: "stroke.error";
|
|
122
|
+
outlineColor: "stroke.error";
|
|
123
|
+
background: "surface.dangerSubtle";
|
|
124
|
+
outlineOffset: "-2px";
|
|
125
|
+
_checked: {
|
|
126
|
+
color: "text.default";
|
|
127
|
+
borderColor: "stroke.error";
|
|
128
|
+
outlineColor: "stroke.error";
|
|
129
|
+
background: "surface.dangerSubtle";
|
|
130
|
+
outlineOffset: "-2px";
|
|
131
|
+
_hover: {
|
|
132
|
+
borderColor: "stroke.hover";
|
|
133
|
+
outlineColor: "stroke.hover";
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
_focus: {
|
|
138
|
+
outlineStyle: "solid";
|
|
139
|
+
outlineWidth: "2px";
|
|
140
|
+
outlineOffset: "-2px";
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
control: {
|
|
144
|
+
display: "none";
|
|
145
|
+
_checked: {
|
|
146
|
+
display: "flex";
|
|
147
|
+
color: "text.onAction";
|
|
148
|
+
_hover: {
|
|
149
|
+
color: "stroke.hover";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
_disabled: {
|
|
153
|
+
color: "stroke.disabled";
|
|
154
|
+
_hover: {
|
|
155
|
+
color: "stroke.disabled";
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
_invalid: {
|
|
159
|
+
_checked: {
|
|
160
|
+
color: "stroke.error";
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}>;
|
|
167
|
+
export type CheckboxVariantProps = RecipeVariantProps<typeof checkboxRecipe>;
|
|
168
|
+
export type CheckboxRootProps = Checkbox.RootProps & CheckboxVariantProps & JsxStyleProps;
|
|
169
|
+
export declare const CheckboxRoot: import("react").ForwardRefExoticComponent<Checkbox.RootProps & {
|
|
170
|
+
variant?: "checkbox" | "chip" | undefined;
|
|
171
|
+
} & {
|
|
172
|
+
forwardCssProp?: boolean | undefined;
|
|
173
|
+
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLLabelElement>>;
|
|
174
|
+
export declare const CheckboxIndicator: import("react").ForwardRefExoticComponent<Checkbox.IndicatorProps & {
|
|
175
|
+
forwardCssProp?: boolean | undefined;
|
|
176
|
+
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLDivElement>>;
|
|
177
|
+
export declare const CheckboxLabel: ({ textStyle, children, ...props }: Checkbox.LabelProps & TextProps & JsxStyleProps) => import("react/jsx-runtime").JSX.Element;
|
|
178
|
+
export declare const CheckboxControl: import("react").ForwardRefExoticComponent<{
|
|
179
|
+
forwardCssProp?: boolean | undefined;
|
|
180
|
+
} & import("@ndla/styled-system/types").WithCss & Checkbox.ControlProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
181
|
export declare const CheckboxHiddenInput: import("react").ForwardRefExoticComponent<Checkbox.HiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
182
|
+
export {};
|
package/lib/Checkbox.js
CHANGED
|
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CheckboxRoot = exports.CheckboxLabel = exports.CheckboxIndicator = exports.CheckboxHiddenInput = exports.CheckboxControl = void 0;
|
|
7
|
-
var _react = require("react");
|
|
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
|
/**
|
|
@@ -28,19 +26,12 @@ const checkboxRecipe = (0, _css.sva)({
|
|
|
28
26
|
display: "flex",
|
|
29
27
|
alignItems: "center",
|
|
30
28
|
cursor: "pointer",
|
|
31
|
-
gap: "xxsmall",
|
|
32
29
|
_disabled: {
|
|
33
30
|
color: "text.disabled",
|
|
34
|
-
cursor: "not-allowed"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
_focus: {
|
|
40
|
-
outline: "2px solid",
|
|
41
|
-
outlineOffset: "4xsmall",
|
|
42
|
-
outlineColor: "stroke.default",
|
|
43
|
-
borderRadius: "xsmall"
|
|
31
|
+
cursor: "not-allowed",
|
|
32
|
+
_hover: {
|
|
33
|
+
color: "text.disabled"
|
|
34
|
+
}
|
|
44
35
|
}
|
|
45
36
|
},
|
|
46
37
|
control: {
|
|
@@ -50,39 +41,167 @@ const checkboxRecipe = (0, _css.sva)({
|
|
|
50
41
|
cursor: "pointer",
|
|
51
42
|
width: "medium",
|
|
52
43
|
height: "medium",
|
|
53
|
-
background: "surface.default",
|
|
54
|
-
borderRadius: "xsmall",
|
|
55
|
-
border: "2px solid",
|
|
56
|
-
borderColor: "stroke.subtle",
|
|
57
44
|
color: "text.strong",
|
|
58
45
|
transitionDuration: "normal",
|
|
59
46
|
transitionProperty: "border-color, background, box-shadow, color",
|
|
60
|
-
transitionTimingFunction: "default"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
transitionTimingFunction: "default"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
variant: "checkbox"
|
|
52
|
+
},
|
|
53
|
+
variants: {
|
|
54
|
+
variant: {
|
|
55
|
+
checkbox: {
|
|
56
|
+
root: {
|
|
57
|
+
gap: "xxsmall",
|
|
58
|
+
_hover: {
|
|
59
|
+
color: "text.action"
|
|
60
|
+
},
|
|
61
|
+
_focus: {
|
|
62
|
+
outline: "2px solid",
|
|
63
|
+
outlineOffset: "4xsmall",
|
|
64
|
+
outlineColor: "stroke.default",
|
|
65
|
+
borderRadius: "xsmall"
|
|
66
|
+
}
|
|
75
67
|
},
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
control: {
|
|
69
|
+
border: "2px solid",
|
|
70
|
+
borderColor: "stroke.subtle",
|
|
71
|
+
borderRadius: "xsmall",
|
|
72
|
+
background: "surface.default",
|
|
73
|
+
_hover: {
|
|
74
|
+
boxShadow: "0 0 0 4px var(--shadow-color)",
|
|
75
|
+
boxShadowColor: "surface.actionSubtle.hover.strong"
|
|
76
|
+
},
|
|
77
|
+
_checked: {
|
|
78
|
+
backgroundColor: "surface.action",
|
|
79
|
+
borderColor: "surface.action",
|
|
80
|
+
color: "icon.onAction"
|
|
81
|
+
},
|
|
82
|
+
_disabled: {
|
|
83
|
+
borderColor: "stroke.disabled",
|
|
84
|
+
_hover: {
|
|
85
|
+
borderColor: "stroke.disabled",
|
|
86
|
+
boxShadow: "none"
|
|
87
|
+
},
|
|
88
|
+
_checked: {
|
|
89
|
+
background: "surface.disabled"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
_invalid: {
|
|
93
|
+
borderColor: "stroke.error",
|
|
94
|
+
_checked: {
|
|
95
|
+
color: "stroke.error",
|
|
96
|
+
borderColor: "stroke.error",
|
|
97
|
+
backgroundColor: "surface.default"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
78
100
|
}
|
|
79
101
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
color: "
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
chip: {
|
|
103
|
+
root: {
|
|
104
|
+
width: "fit-content",
|
|
105
|
+
color: "text.default",
|
|
106
|
+
gap: "4xsmall",
|
|
107
|
+
background: "surface.actionSubtle",
|
|
108
|
+
border: "1px solid",
|
|
109
|
+
borderColor: "stroke.subtle",
|
|
110
|
+
outlineColor: "stroke.subtle",
|
|
111
|
+
paddingInline: "xsmall",
|
|
112
|
+
paddingBlock: "4xsmall",
|
|
113
|
+
borderRadius: "large",
|
|
114
|
+
minHeight: "large",
|
|
115
|
+
transitionDuration: "normal",
|
|
116
|
+
transitionProperty: "border-color, background, box-shadow, color",
|
|
117
|
+
transitionTimingFunction: "default",
|
|
118
|
+
_disabled: {
|
|
119
|
+
color: "text.disabled",
|
|
120
|
+
borderColor: "stroke.disabled",
|
|
121
|
+
background: "surface.disabled",
|
|
122
|
+
_hover: {
|
|
123
|
+
color: "text.disabled",
|
|
124
|
+
borderColor: "stroke.disabled",
|
|
125
|
+
background: "surface.disabled"
|
|
126
|
+
},
|
|
127
|
+
_checked: {
|
|
128
|
+
color: "text.disabled",
|
|
129
|
+
borderColor: "stroke.disabled",
|
|
130
|
+
background: "surface.disabled",
|
|
131
|
+
_hover: {
|
|
132
|
+
color: "text.disabled",
|
|
133
|
+
borderColor: "stroke.disabled",
|
|
134
|
+
background: "surface.disabled"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
_hover: {
|
|
139
|
+
background: "surface.actionSubtle.hover",
|
|
140
|
+
borderColor: "stroke.hover",
|
|
141
|
+
outlineColor: "stroke.hover",
|
|
142
|
+
_invalid: {
|
|
143
|
+
backgroundColor: "surface.dangerSubtle"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
_checked: {
|
|
147
|
+
color: "text.onAction",
|
|
148
|
+
background: "surface.actionSubtle.selected",
|
|
149
|
+
borderColor: "surface.actionSubtle.selected",
|
|
150
|
+
outlineColor: "icon.onAction",
|
|
151
|
+
_focus: {
|
|
152
|
+
outlineOffset: "-4px"
|
|
153
|
+
},
|
|
154
|
+
_hover: {
|
|
155
|
+
outlineOffset: "-2px",
|
|
156
|
+
background: "surface.actionSubtle.hover",
|
|
157
|
+
color: "text.default",
|
|
158
|
+
borderColor: "stroke.hover",
|
|
159
|
+
outlineColor: "stroke.hover"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
_invalid: {
|
|
163
|
+
borderColor: "stroke.error",
|
|
164
|
+
outlineColor: "stroke.error",
|
|
165
|
+
background: "surface.dangerSubtle",
|
|
166
|
+
outlineOffset: "-2px",
|
|
167
|
+
_checked: {
|
|
168
|
+
color: "text.default",
|
|
169
|
+
borderColor: "stroke.error",
|
|
170
|
+
outlineColor: "stroke.error",
|
|
171
|
+
background: "surface.dangerSubtle",
|
|
172
|
+
outlineOffset: "-2px",
|
|
173
|
+
_hover: {
|
|
174
|
+
borderColor: "stroke.hover",
|
|
175
|
+
outlineColor: "stroke.hover"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
_focus: {
|
|
180
|
+
outlineStyle: "solid",
|
|
181
|
+
outlineWidth: "2px",
|
|
182
|
+
outlineOffset: "-2px"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
control: {
|
|
186
|
+
display: "none",
|
|
187
|
+
_checked: {
|
|
188
|
+
display: "flex",
|
|
189
|
+
color: "text.onAction",
|
|
190
|
+
_hover: {
|
|
191
|
+
color: "stroke.hover"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
_disabled: {
|
|
195
|
+
color: "stroke.disabled",
|
|
196
|
+
_hover: {
|
|
197
|
+
color: "stroke.disabled"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
_invalid: {
|
|
201
|
+
_checked: {
|
|
202
|
+
color: "stroke.error"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
86
205
|
}
|
|
87
206
|
}
|
|
88
207
|
}
|
|
@@ -92,19 +211,9 @@ const {
|
|
|
92
211
|
withProvider,
|
|
93
212
|
withContext
|
|
94
213
|
} = (0, _createStyleContext.createStyleContext)(checkboxRecipe);
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const field = (0, _FormControl.useFormControl)(props);
|
|
99
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalCheckboxRoot, {
|
|
100
|
-
...field,
|
|
101
|
-
invalid: (_field$invalid = field.invalid) !== null && _field$invalid !== void 0 ? _field$invalid : !!field["aria-invalid"],
|
|
102
|
-
ref: ref,
|
|
103
|
-
"aria-invalid": undefined
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
const CheckboxIndicator = exports.CheckboxIndicator = withContext(_react2.Checkbox.Indicator, "indicator");
|
|
107
|
-
const InternalCheckboxLabel = withContext(_react2.Checkbox.Label, "label");
|
|
214
|
+
const CheckboxRoot = exports.CheckboxRoot = withProvider(_react.Checkbox.Root, "root");
|
|
215
|
+
const CheckboxIndicator = exports.CheckboxIndicator = withContext(_react.Checkbox.Indicator, "indicator");
|
|
216
|
+
const InternalCheckboxLabel = withContext(_react.Checkbox.Label, "label");
|
|
108
217
|
const CheckboxLabel = _ref => {
|
|
109
218
|
let {
|
|
110
219
|
textStyle = "label.medium",
|
|
@@ -121,5 +230,5 @@ const CheckboxLabel = _ref => {
|
|
|
121
230
|
});
|
|
122
231
|
};
|
|
123
232
|
exports.CheckboxLabel = CheckboxLabel;
|
|
124
|
-
const CheckboxControl = exports.CheckboxControl = withContext(
|
|
125
|
-
const CheckboxHiddenInput = exports.CheckboxHiddenInput =
|
|
233
|
+
const CheckboxControl = exports.CheckboxControl = withContext(_react.Checkbox.Control, "control");
|
|
234
|
+
const CheckboxHiddenInput = exports.CheckboxHiddenInput = _react.Checkbox.HiddenInput;
|