@ndla/primitives 0.0.3 → 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 +49 -26
- package/dist/styles.css +170 -80
- package/es/BlockQuote.js +2 -2
- package/es/Checkbox.js +160 -51
- package/es/Field.js +17 -0
- package/es/FieldErrorMessage.js +6 -12
- package/es/FieldHelper.js +6 -11
- package/es/Input.js +13 -14
- package/es/Label.js +6 -31
- package/es/RadioGroup.js +1 -9
- package/es/Switch.js +1 -12
- package/es/Tabs.js +2 -3
- package/lib/BlockQuote.d.ts +1 -0
- package/lib/BlockQuote.js +2 -2
- package/lib/Checkbox.d.ts +162 -2
- package/lib/Checkbox.js +165 -56
- package/lib/Field.d.ts +9 -0
- package/lib/Field.js +23 -0
- package/lib/FieldErrorMessage.js +5 -11
- package/lib/FieldHelper.js +5 -10
- package/lib/Input.d.ts +2 -2
- package/lib/Input.js +13 -14
- package/lib/Label.d.ts +1 -4
- package/lib/Label.js +6 -31
- package/lib/RadioGroup.js +1 -9
- package/lib/Switch.js +6 -17
- package/lib/Tabs.js +2 -3
- package/package.json +3 -3
- package/es/FormControl.js +0 -164
- package/lib/FormControl.d.ts +0 -67
- package/lib/FormControl.js +0 -174
package/lib/Checkbox.d.ts
CHANGED
|
@@ -6,10 +6,169 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import { Checkbox } from "@ark-ui/react";
|
|
9
|
-
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
9
|
+
import { JsxStyleProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
10
|
import { TextProps } from "./Text";
|
|
11
|
-
|
|
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;
|
|
12
169
|
export declare const CheckboxRoot: import("react").ForwardRefExoticComponent<Checkbox.RootProps & {
|
|
170
|
+
variant?: "checkbox" | "chip" | undefined;
|
|
171
|
+
} & {
|
|
13
172
|
forwardCssProp?: boolean | undefined;
|
|
14
173
|
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLLabelElement>>;
|
|
15
174
|
export declare const CheckboxIndicator: import("react").ForwardRefExoticComponent<Checkbox.IndicatorProps & {
|
|
@@ -20,3 +179,4 @@ export declare const CheckboxControl: import("react").ForwardRefExoticComponent<
|
|
|
20
179
|
forwardCssProp?: boolean | undefined;
|
|
21
180
|
} & import("@ndla/styled-system/types").WithCss & Checkbox.ControlProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
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;
|
package/lib/Field.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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 { Field } from "@ark-ui/react";
|
|
9
|
+
export declare const FieldRoot: import("@ndla/styled-system/jsx").StyledComponent<import("react").ForwardRefExoticComponent<Field.RootProps & import("react").RefAttributes<HTMLDivElement>>, {}>;
|
package/lib/Field.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FieldRoot = void 0;
|
|
7
|
+
var _react = require("@ark-ui/react");
|
|
8
|
+
var _jsx = require("@ndla/styled-system/jsx");
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) 2024-present, NDLA.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const FieldRoot = exports.FieldRoot = (0, _jsx.styled)(_react.Field.Root, {
|
|
18
|
+
base: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
gap: "3xsmall"
|
|
22
|
+
}
|
|
23
|
+
});
|
package/lib/FieldErrorMessage.js
CHANGED
|
@@ -8,7 +8,6 @@ var _react = require("react");
|
|
|
8
8
|
var _react2 = require("@ark-ui/react");
|
|
9
9
|
var _css = require("@ndla/styled-system/css");
|
|
10
10
|
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
11
|
-
var _FormControl = require("./FormControl");
|
|
12
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
12
|
/**
|
|
14
13
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -18,7 +17,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
17
|
*
|
|
19
18
|
*/
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const StyledErrorText = (0, _jsx2.styled)(_react2.Field.ErrorText, {
|
|
22
21
|
base: {
|
|
23
22
|
color: "text.error",
|
|
24
23
|
whiteSpace: "pre-line",
|
|
@@ -26,7 +25,6 @@ const StyledErrorMessage = (0, _jsx2.styled)(_react2.ark.div, {
|
|
|
26
25
|
}
|
|
27
26
|
});
|
|
28
27
|
const FieldErrorMessage = exports.FieldErrorMessage = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
29
|
-
var _field$getErrorMessag;
|
|
30
28
|
let {
|
|
31
29
|
textStyle = "label.small",
|
|
32
30
|
fontWeight,
|
|
@@ -35,18 +33,14 @@ const FieldErrorMessage = exports.FieldErrorMessage = /*#__PURE__*/(0, _react.fo
|
|
|
35
33
|
srOnly,
|
|
36
34
|
...props
|
|
37
35
|
} = _ref;
|
|
38
|
-
|
|
39
|
-
if (field && !field.isInvalid) return null;
|
|
40
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledErrorMessage, {
|
|
41
|
-
...((_field$getErrorMessag = field === null || field === void 0 ? void 0 : field.getErrorMessageProps(props, ref)) !== null && _field$getErrorMessag !== void 0 ? _field$getErrorMessag : {
|
|
42
|
-
ref,
|
|
43
|
-
...props
|
|
44
|
-
}),
|
|
36
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledErrorText, {
|
|
45
37
|
css: _css.css.raw({
|
|
46
38
|
textStyle,
|
|
47
39
|
fontWeight,
|
|
48
40
|
color,
|
|
49
41
|
srOnly
|
|
50
|
-
}, cssProp)
|
|
42
|
+
}, cssProp),
|
|
43
|
+
...props,
|
|
44
|
+
ref: ref
|
|
51
45
|
});
|
|
52
46
|
});
|
package/lib/FieldHelper.js
CHANGED
|
@@ -8,7 +8,6 @@ var _react = require("react");
|
|
|
8
8
|
var _react2 = require("@ark-ui/react");
|
|
9
9
|
var _css = require("@ndla/styled-system/css");
|
|
10
10
|
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
11
|
-
var _FormControl = require("./FormControl");
|
|
12
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
12
|
/**
|
|
14
13
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -18,9 +17,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
17
|
*
|
|
19
18
|
*/
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const StyledFieldHelper = (0, _jsx2.styled)(_react2.Field.HelperText);
|
|
22
21
|
const FieldHelper = exports.FieldHelper = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
23
|
-
var _field$getHelpTextPro;
|
|
24
22
|
let {
|
|
25
23
|
textStyle = "label.small",
|
|
26
24
|
fontWeight,
|
|
@@ -29,17 +27,14 @@ const FieldHelper = exports.FieldHelper = /*#__PURE__*/(0, _react.forwardRef)((_
|
|
|
29
27
|
css: cssProp,
|
|
30
28
|
...props
|
|
31
29
|
} = _ref;
|
|
32
|
-
|
|
33
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDiv, {
|
|
34
|
-
...((_field$getHelpTextPro = field === null || field === void 0 ? void 0 : field.getHelpTextProps(props, ref)) !== null && _field$getHelpTextPro !== void 0 ? _field$getHelpTextPro : {
|
|
35
|
-
ref,
|
|
36
|
-
...props
|
|
37
|
-
}),
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFieldHelper, {
|
|
38
31
|
css: _css.css.raw({
|
|
39
32
|
textStyle,
|
|
40
33
|
fontWeight,
|
|
41
34
|
color,
|
|
42
35
|
srOnly
|
|
43
|
-
}, cssProp)
|
|
36
|
+
}, cssProp),
|
|
37
|
+
...props,
|
|
38
|
+
ref: ref
|
|
44
39
|
});
|
|
45
40
|
});
|
package/lib/Input.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export declare const InputContainer: import("react").ForwardRefExoticComponent<O
|
|
|
13
13
|
export interface InputProps extends HTMLArkProps<"input">, JsxStyleProps {
|
|
14
14
|
}
|
|
15
15
|
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const FieldInput: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
17
17
|
interface TextAreaProps extends HTMLArkProps<"textarea">, JsxStyleProps {
|
|
18
18
|
}
|
|
19
19
|
export declare const TextArea: import("react").ForwardRefExoticComponent<TextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const FieldTextArea: import("react").ForwardRefExoticComponent<TextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
21
21
|
export {};
|
package/lib/Input.js
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TextArea = exports.InputContainer = exports.Input = exports.
|
|
6
|
+
exports.TextArea = exports.InputContainer = exports.Input = exports.FieldTextArea = exports.FieldInput = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _react2 = require("@ark-ui/react");
|
|
9
9
|
var _css = require("@ndla/styled-system/css");
|
|
10
10
|
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
11
11
|
var _util = require("@ndla/util");
|
|
12
|
-
var _FormControl = require("./FormControl");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
13
|
/**
|
|
15
14
|
* Copyright (c) 2024-present, NDLA.
|
|
@@ -122,13 +121,13 @@ const Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =
|
|
|
122
121
|
...props
|
|
123
122
|
});
|
|
124
123
|
});
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
...
|
|
124
|
+
const FieldInput = exports.FieldInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Field.Input, {
|
|
125
|
+
asChild: true,
|
|
126
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Input, {
|
|
127
|
+
...props,
|
|
129
128
|
ref: ref
|
|
130
|
-
})
|
|
131
|
-
});
|
|
129
|
+
})
|
|
130
|
+
}));
|
|
132
131
|
const StyledTextArea = (0, _jsx2.styled)(_react2.ark.textarea);
|
|
133
132
|
const TextArea = exports.TextArea = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
134
133
|
let {
|
|
@@ -159,10 +158,10 @@ const TextArea = exports.TextArea = /*#__PURE__*/(0, _react.forwardRef)((_ref3,
|
|
|
159
158
|
...props
|
|
160
159
|
});
|
|
161
160
|
});
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
...
|
|
161
|
+
const FieldTextArea = exports.FieldTextArea = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Field.Textarea, {
|
|
162
|
+
asChild: true,
|
|
163
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TextArea, {
|
|
164
|
+
...props,
|
|
166
165
|
ref: ref
|
|
167
|
-
})
|
|
168
|
-
});
|
|
166
|
+
})
|
|
167
|
+
}));
|
package/lib/Label.d.ts
CHANGED
|
@@ -12,14 +12,11 @@ export type LegendProps = HTMLArkProps<"legend"> & JsxStyleProps & TextProps;
|
|
|
12
12
|
export declare const Legend: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & {
|
|
13
13
|
forwardCssProp?: boolean | undefined;
|
|
14
14
|
} & import("@ndla/styled-system/types").WithCss & TextProps & import("react").RefAttributes<HTMLLegendElement>>;
|
|
15
|
-
export declare const FormLegend: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & {
|
|
16
|
-
forwardCssProp?: boolean | undefined;
|
|
17
|
-
} & import("@ndla/styled-system/types").WithCss & TextProps & import("react").RefAttributes<HTMLLegendElement>>;
|
|
18
15
|
export type LabelProps = HTMLArkProps<"label"> & TextProps & JsxStyleProps;
|
|
19
16
|
export declare const Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & TextProps & {
|
|
20
17
|
forwardCssProp?: boolean | undefined;
|
|
21
18
|
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLLabelElement>>;
|
|
22
|
-
export declare const
|
|
19
|
+
export declare const FieldLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & import("@ark-ui/react").PolymorphicProps & TextProps & {
|
|
23
20
|
forwardCssProp?: boolean | undefined;
|
|
24
21
|
} & import("@ndla/styled-system/types").WithCss & import("react").RefAttributes<HTMLLabelElement>>;
|
|
25
22
|
export declare const Fieldset: import("@ndla/styled-system/jsx").StyledComponent<"fieldset", {}>;
|