@ndla/primitives 0.0.8 → 0.0.10
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 +80 -31
- package/dist/styles.css +292 -101
- package/es/Accordion.js +1 -2
- package/es/Button.js +4 -0
- package/es/Checkbox.js +1 -2
- package/es/Combobox.js +226 -0
- package/es/Dialog.js +1 -2
- package/es/Figure.js +75 -0
- package/es/Menu.js +1 -2
- package/es/Pagination.js +1 -2
- package/es/Popover.js +1 -2
- package/es/RadioGroup.js +1 -2
- package/es/Select.js +197 -0
- package/es/Slider.js +1 -2
- package/es/Switch.js +1 -2
- package/es/Tabs.js +2 -3
- package/es/TagsInput.js +121 -0
- package/es/Toast.js +1 -2
- package/es/Tooltip.js +1 -2
- package/es/storybookHelpers/data.js +212 -0
- package/lib/Accordion.js +1 -2
- package/lib/Button.js +4 -0
- package/lib/Checkbox.js +1 -2
- package/lib/Combobox.d.ts +59 -0
- package/lib/Combobox.js +236 -0
- package/lib/Dialog.d.ts +1 -1
- package/lib/Dialog.js +1 -2
- package/lib/Figure.d.ts +11 -0
- package/lib/Figure.js +81 -0
- package/lib/Menu.js +1 -2
- package/lib/Pagination.js +1 -2
- package/lib/Popover.js +1 -2
- package/lib/RadioGroup.js +1 -2
- package/lib/Select.d.ts +51 -0
- package/lib/Select.js +204 -0
- package/lib/Slider.js +1 -2
- package/lib/Switch.js +1 -2
- package/lib/Tabs.js +1 -2
- package/lib/TagsInput.d.ts +41 -0
- package/lib/TagsInput.js +127 -0
- package/lib/Toast.js +1 -2
- package/lib/Tooltip.js +1 -2
- package/lib/storybookHelpers/data.d.ts +23 -0
- package/lib/storybookHelpers/data.js +218 -0
- package/package.json +7 -8
package/es/TagsInput.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
|
|
9
|
+
import { forwardRef } from "react";
|
|
10
|
+
import { TagsInput, tagsInputAnatomy } from "@ark-ui/react";
|
|
11
|
+
import { sva } from "@ndla/styled-system/css";
|
|
12
|
+
import { createStyleContext } from "./createStyleContext";
|
|
13
|
+
import { Label } from "./Label";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const tagsInputRecipe = sva({
|
|
16
|
+
slots: tagsInputAnatomy.keys(),
|
|
17
|
+
base: {
|
|
18
|
+
root: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
gap: "xxsmall",
|
|
22
|
+
width: "full"
|
|
23
|
+
},
|
|
24
|
+
control: {
|
|
25
|
+
display: "inline-flex",
|
|
26
|
+
gap: "xxsmall",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
flexWrap: "wrap"
|
|
29
|
+
},
|
|
30
|
+
item: {
|
|
31
|
+
paddingBlock: "3xsmall"
|
|
32
|
+
},
|
|
33
|
+
itemPreview: {
|
|
34
|
+
display: "flex",
|
|
35
|
+
gap: "1",
|
|
36
|
+
paddingBlock: "4xsmall",
|
|
37
|
+
paddingInlineEnd: "3xsmall",
|
|
38
|
+
paddingInlineStart: "xsmall",
|
|
39
|
+
cursor: "initial",
|
|
40
|
+
borderRadius: "large",
|
|
41
|
+
outline: "1px solid",
|
|
42
|
+
outlineColor: "transparent",
|
|
43
|
+
backgroundColor: "surface.actionSubtle.selected",
|
|
44
|
+
color: "text.onAction",
|
|
45
|
+
transitionDuration: "normal",
|
|
46
|
+
transitionProperty: "background, outline-color, color",
|
|
47
|
+
transitionTimingFunction: "default",
|
|
48
|
+
textStyle: "label.medium",
|
|
49
|
+
_hover: {
|
|
50
|
+
backgroundColor: "surface.actionSubtle.hover",
|
|
51
|
+
outlineColor: "stroke.hover",
|
|
52
|
+
color: "text.default",
|
|
53
|
+
"& svg": {
|
|
54
|
+
color: "stroke.hover"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
_highlighted: {
|
|
58
|
+
backgroundColor: "surface.actionSubtle.hover",
|
|
59
|
+
outlineWidth: "3px",
|
|
60
|
+
outlineOffset: "-1px",
|
|
61
|
+
outlineColor: "stroke.hover",
|
|
62
|
+
color: "text.default",
|
|
63
|
+
"& svg": {
|
|
64
|
+
color: "stroke.hover"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
input: {
|
|
69
|
+
flex: "1"
|
|
70
|
+
},
|
|
71
|
+
itemDeleteTrigger: {
|
|
72
|
+
paddingBottom: "1",
|
|
73
|
+
cursor: "pointer",
|
|
74
|
+
"& span": {
|
|
75
|
+
display: "inline-block"
|
|
76
|
+
},
|
|
77
|
+
"& svg": {
|
|
78
|
+
marginInline: "0",
|
|
79
|
+
marginBlock: "0",
|
|
80
|
+
width: "medium",
|
|
81
|
+
height: "medium"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
itemText: {
|
|
85
|
+
paddingBottom: "1"
|
|
86
|
+
},
|
|
87
|
+
itemInput: {
|
|
88
|
+
outline: "none",
|
|
89
|
+
background: "transparent"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const {
|
|
94
|
+
withProvider,
|
|
95
|
+
withContext
|
|
96
|
+
} = createStyleContext(tagsInputRecipe);
|
|
97
|
+
export const TagsInputRoot = withProvider(TagsInput.Root, "root");
|
|
98
|
+
export const TagsInputClearTrigger = withContext(TagsInput.ClearTrigger, "clearTrigger");
|
|
99
|
+
export const TagsInputControl = withContext(TagsInput.Control, "control");
|
|
100
|
+
export const TagsInputInput = withContext(TagsInput.Input, "input");
|
|
101
|
+
export const TagsInputItemDeleteTrigger = withContext(TagsInput.ItemDeleteTrigger, "itemDeleteTrigger");
|
|
102
|
+
export const TagsInputItemInput = withContext(TagsInput.ItemInput, "itemInput");
|
|
103
|
+
export const TagsInputItemPreview = withContext(TagsInput.ItemPreview, "itemPreview");
|
|
104
|
+
export const TagsInputItem = withContext(TagsInput.Item, "item");
|
|
105
|
+
export const TagsInputItemText = withContext(TagsInput.ItemText, "itemText");
|
|
106
|
+
const InternalTagsInputLabel = withContext(TagsInput.Label, "label");
|
|
107
|
+
export const TagsInputLabel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
108
|
+
let {
|
|
109
|
+
children,
|
|
110
|
+
...props
|
|
111
|
+
} = _ref;
|
|
112
|
+
return /*#__PURE__*/_jsx(InternalTagsInputLabel, {
|
|
113
|
+
asChild: true,
|
|
114
|
+
forwardCssProp: true,
|
|
115
|
+
ref: ref,
|
|
116
|
+
...props,
|
|
117
|
+
children: /*#__PURE__*/_jsx(Label, {
|
|
118
|
+
children: children
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
});
|
package/es/Toast.js
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { toastAnatomy } from "@ark-ui/
|
|
10
|
-
import { Toast } from "@ark-ui/react";
|
|
9
|
+
import { Toast, toastAnatomy } from "@ark-ui/react";
|
|
11
10
|
import { sva } from "@ndla/styled-system/css";
|
|
12
11
|
import { createStyleContext } from "./createStyleContext";
|
|
13
12
|
import { Text } from "./Text";
|
package/es/Tooltip.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { forwardRef } from "react";
|
|
10
|
-
import { tooltipAnatomy } from "@ark-ui/
|
|
11
|
-
import { Tooltip } from "@ark-ui/react";
|
|
10
|
+
import { Tooltip, tooltipAnatomy } from "@ark-ui/react";
|
|
12
11
|
import { sva } from "@ndla/styled-system/css";
|
|
13
12
|
import { createStyleContext } from "./createStyleContext";
|
|
14
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
|
|
9
|
+
export const europeanCountries = [{
|
|
10
|
+
label: "Albania",
|
|
11
|
+
value: "AL"
|
|
12
|
+
}, {
|
|
13
|
+
label: "Andorra",
|
|
14
|
+
value: "AD"
|
|
15
|
+
}, {
|
|
16
|
+
label: "Armenia",
|
|
17
|
+
value: "AM"
|
|
18
|
+
}, {
|
|
19
|
+
label: "Austria",
|
|
20
|
+
value: "AT"
|
|
21
|
+
}, {
|
|
22
|
+
label: "Azerbaijan",
|
|
23
|
+
value: "AZ"
|
|
24
|
+
}, {
|
|
25
|
+
label: "Belarus",
|
|
26
|
+
value: "BY"
|
|
27
|
+
}, {
|
|
28
|
+
label: "Belgium",
|
|
29
|
+
value: "BE"
|
|
30
|
+
}, {
|
|
31
|
+
label: "Bosnia and Herzegovina",
|
|
32
|
+
value: "BA"
|
|
33
|
+
}, {
|
|
34
|
+
label: "Bulgaria",
|
|
35
|
+
value: "BG"
|
|
36
|
+
}, {
|
|
37
|
+
label: "Croatia",
|
|
38
|
+
value: "HR"
|
|
39
|
+
}, {
|
|
40
|
+
label: "Cyprus",
|
|
41
|
+
value: "CY"
|
|
42
|
+
}, {
|
|
43
|
+
label: "Czech Republic",
|
|
44
|
+
value: "CZ"
|
|
45
|
+
}, {
|
|
46
|
+
label: "Denmark",
|
|
47
|
+
value: "DK"
|
|
48
|
+
}, {
|
|
49
|
+
label: "Estonia",
|
|
50
|
+
value: "EE"
|
|
51
|
+
}, {
|
|
52
|
+
label: "Finland",
|
|
53
|
+
value: "FI"
|
|
54
|
+
}, {
|
|
55
|
+
label: "France",
|
|
56
|
+
value: "FR"
|
|
57
|
+
}, {
|
|
58
|
+
label: "Georgia",
|
|
59
|
+
value: "GE"
|
|
60
|
+
}, {
|
|
61
|
+
label: "Germany",
|
|
62
|
+
value: "DE"
|
|
63
|
+
}, {
|
|
64
|
+
label: "Greece",
|
|
65
|
+
value: "GR"
|
|
66
|
+
}, {
|
|
67
|
+
label: "Hungary",
|
|
68
|
+
value: "HU"
|
|
69
|
+
}, {
|
|
70
|
+
label: "Iceland",
|
|
71
|
+
value: "IS"
|
|
72
|
+
}, {
|
|
73
|
+
label: "Ireland",
|
|
74
|
+
value: "IE"
|
|
75
|
+
}, {
|
|
76
|
+
label: "Italy",
|
|
77
|
+
value: "IT"
|
|
78
|
+
}, {
|
|
79
|
+
label: "Kazakhstan",
|
|
80
|
+
value: "KZ"
|
|
81
|
+
}, {
|
|
82
|
+
label: "Kosovo",
|
|
83
|
+
value: "XK"
|
|
84
|
+
}, {
|
|
85
|
+
label: "Latvia",
|
|
86
|
+
value: "LV"
|
|
87
|
+
}, {
|
|
88
|
+
label: "Liechtenstein",
|
|
89
|
+
value: "LI"
|
|
90
|
+
}, {
|
|
91
|
+
label: "Lithuania",
|
|
92
|
+
value: "LT"
|
|
93
|
+
}, {
|
|
94
|
+
label: "Luxembourg",
|
|
95
|
+
value: "LU"
|
|
96
|
+
}, {
|
|
97
|
+
label: "Malta",
|
|
98
|
+
value: "MT"
|
|
99
|
+
}, {
|
|
100
|
+
label: "Moldova",
|
|
101
|
+
value: "MD"
|
|
102
|
+
}, {
|
|
103
|
+
label: "Monaco",
|
|
104
|
+
value: "MC"
|
|
105
|
+
}, {
|
|
106
|
+
label: "Montenegro",
|
|
107
|
+
value: "ME"
|
|
108
|
+
}, {
|
|
109
|
+
label: "Netherlands",
|
|
110
|
+
value: "NL"
|
|
111
|
+
}, {
|
|
112
|
+
label: "North Macedonia",
|
|
113
|
+
value: "MK"
|
|
114
|
+
}, {
|
|
115
|
+
label: "Norway",
|
|
116
|
+
value: "NO"
|
|
117
|
+
}, {
|
|
118
|
+
label: "Poland",
|
|
119
|
+
value: "PL"
|
|
120
|
+
}, {
|
|
121
|
+
label: "Portugal",
|
|
122
|
+
value: "PT"
|
|
123
|
+
}, {
|
|
124
|
+
label: "Romania",
|
|
125
|
+
value: "RO"
|
|
126
|
+
}, {
|
|
127
|
+
label: "Russia",
|
|
128
|
+
value: "RU"
|
|
129
|
+
}, {
|
|
130
|
+
label: "San Marino",
|
|
131
|
+
value: "SM"
|
|
132
|
+
}, {
|
|
133
|
+
label: "Serbia",
|
|
134
|
+
value: "RS"
|
|
135
|
+
}, {
|
|
136
|
+
label: "Slovakia",
|
|
137
|
+
value: "SK"
|
|
138
|
+
}, {
|
|
139
|
+
label: "Slovenia",
|
|
140
|
+
value: "SI"
|
|
141
|
+
}, {
|
|
142
|
+
label: "Spain",
|
|
143
|
+
value: "ES"
|
|
144
|
+
}, {
|
|
145
|
+
label: "Sweden",
|
|
146
|
+
value: "SE"
|
|
147
|
+
}, {
|
|
148
|
+
label: "Switzerland",
|
|
149
|
+
value: "CH"
|
|
150
|
+
}, {
|
|
151
|
+
label: "Turkey",
|
|
152
|
+
value: "TR"
|
|
153
|
+
}, {
|
|
154
|
+
label: "Ukraine",
|
|
155
|
+
value: "UA"
|
|
156
|
+
}, {
|
|
157
|
+
label: "United Kingdom",
|
|
158
|
+
value: "GB"
|
|
159
|
+
}, {
|
|
160
|
+
label: "Vatican City",
|
|
161
|
+
value: "VA"
|
|
162
|
+
}];
|
|
163
|
+
export const measurements = [{
|
|
164
|
+
label: "Kilometer",
|
|
165
|
+
value: "km"
|
|
166
|
+
}, {
|
|
167
|
+
label: "Meter",
|
|
168
|
+
value: "m"
|
|
169
|
+
}, {
|
|
170
|
+
label: "Centimeter",
|
|
171
|
+
value: "cm"
|
|
172
|
+
}, {
|
|
173
|
+
label: "Millimeter",
|
|
174
|
+
value: "mm"
|
|
175
|
+
}, {
|
|
176
|
+
label: "Mile",
|
|
177
|
+
value: "mi"
|
|
178
|
+
}, {
|
|
179
|
+
label: "Yard",
|
|
180
|
+
value: "yd"
|
|
181
|
+
}, {
|
|
182
|
+
label: "Foot",
|
|
183
|
+
value: "ft"
|
|
184
|
+
}, {
|
|
185
|
+
label: "Inch",
|
|
186
|
+
value: "in"
|
|
187
|
+
}, {
|
|
188
|
+
label: "Nautical mile",
|
|
189
|
+
value: "nmi"
|
|
190
|
+
}];
|
|
191
|
+
export const advancedItems = [{
|
|
192
|
+
label: "React",
|
|
193
|
+
value: "react",
|
|
194
|
+
description: "A JavaScript library for building user interfaces",
|
|
195
|
+
img: "https://api.test.ndla.no/image-api/raw/YQyWgMkg.png"
|
|
196
|
+
}, {
|
|
197
|
+
label: "Solid",
|
|
198
|
+
value: "solid",
|
|
199
|
+
description: "React, but with signals",
|
|
200
|
+
img: "https://api.test.ndla.no/image-api/raw/YQyWgMkg.png"
|
|
201
|
+
}, {
|
|
202
|
+
label: "Svelte",
|
|
203
|
+
value: "svelte",
|
|
204
|
+
disabled: true,
|
|
205
|
+
description: "No more JS than required",
|
|
206
|
+
img: "https://api.test.ndla.no/image-api/raw/YQyWgMkg.png"
|
|
207
|
+
}, {
|
|
208
|
+
label: "Vue",
|
|
209
|
+
value: "vue",
|
|
210
|
+
description: "The Progressive JavaScript Framework",
|
|
211
|
+
img: "https://api.test.ndla.no/image-api/raw/YQyWgMkg.png"
|
|
212
|
+
}];
|
package/lib/Accordion.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AccordionRoot = exports.AccordionItemTrigger = exports.AccordionItemIndicator = exports.AccordionItemContent = exports.AccordionItem = void 0;
|
|
7
|
-
var _anatomy = require("@ark-ui/anatomy");
|
|
8
7
|
var _react = require("@ark-ui/react");
|
|
9
8
|
var _css = require("@ndla/styled-system/css");
|
|
10
9
|
var _createStyleContext = require("./createStyleContext");
|
|
@@ -17,7 +16,7 @@ var _createStyleContext = require("./createStyleContext");
|
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
const accordionRecipe = (0, _css.sva)({
|
|
20
|
-
slots:
|
|
19
|
+
slots: _react.accordionAnatomy.keys(),
|
|
21
20
|
base: {
|
|
22
21
|
root: {
|
|
23
22
|
display: "flex",
|
package/lib/Button.js
CHANGED
|
@@ -38,6 +38,10 @@ const buttonBaseRecipe = exports.buttonBaseRecipe = (0, _css.cva)({
|
|
|
38
38
|
cursor: "not-allowed",
|
|
39
39
|
color: "text.onAction",
|
|
40
40
|
background: "surface.disabled",
|
|
41
|
+
boxShadowColor: "surface.disabled",
|
|
42
|
+
"& svg": {
|
|
43
|
+
color: "text.onAction"
|
|
44
|
+
},
|
|
41
45
|
_hover: {
|
|
42
46
|
color: "text.onAction",
|
|
43
47
|
background: "surface.disabled"
|
package/lib/Checkbox.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CheckboxRoot = exports.CheckboxLabel = exports.CheckboxIndicator = exports.CheckboxHiddenInput = exports.CheckboxGroup = exports.CheckboxControl = void 0;
|
|
7
|
-
var _anatomy = require("@ark-ui/anatomy");
|
|
8
7
|
var _react = require("@ark-ui/react");
|
|
9
8
|
var _css = require("@ndla/styled-system/css");
|
|
10
9
|
var _createStyleContext = require("./createStyleContext");
|
|
@@ -19,7 +18,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
19
18
|
*/
|
|
20
19
|
|
|
21
20
|
const checkboxRecipe = (0, _css.sva)({
|
|
22
|
-
slots:
|
|
21
|
+
slots: _react.checkboxAnatomy.keys(),
|
|
23
22
|
base: {
|
|
24
23
|
root: {
|
|
25
24
|
userSelect: "none",
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { Combobox } from "@ark-ui/react";
|
|
9
|
+
import { JsxStyleProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
10
|
+
import { TextProps } from "./Text";
|
|
11
|
+
declare const comboboxRecipe: import("@ndla/styled-system/types").SlotRecipeRuntimeFn<"input" | "label" | "content" | "list" | "root" | "item" | "itemIndicator" | "control" | "clearTrigger" | "itemGroup" | "itemGroupLabel" | "itemText" | "positioner" | "trigger", {
|
|
12
|
+
variant: {
|
|
13
|
+
simple: {
|
|
14
|
+
item: {
|
|
15
|
+
padding: "xsmall";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
bordered: {
|
|
19
|
+
item: {
|
|
20
|
+
paddingInline: "small";
|
|
21
|
+
paddingBlock: "xsmall";
|
|
22
|
+
border: "1px solid";
|
|
23
|
+
borderColor: "stroke.subtle";
|
|
24
|
+
_hover: {
|
|
25
|
+
borderColor: "stroke.hover";
|
|
26
|
+
background: "surface.default";
|
|
27
|
+
};
|
|
28
|
+
_highlighted: {
|
|
29
|
+
borderColor: "stroke.default";
|
|
30
|
+
};
|
|
31
|
+
_checked: {
|
|
32
|
+
borderColor: "stroke.default";
|
|
33
|
+
};
|
|
34
|
+
_disabled: {
|
|
35
|
+
borderColor: "stroke.disabled";
|
|
36
|
+
_hover: {
|
|
37
|
+
borderColor: "stroke.disabled";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
type ComboboxVariantProps = RecipeVariantProps<typeof comboboxRecipe>;
|
|
45
|
+
export type ComboboxRootProps<T extends Combobox.CollectionItem> = Combobox.RootProps<T> & ComboboxVariantProps;
|
|
46
|
+
export declare const ComboboxRoot: <T extends Combobox.CollectionItem>({ ...props }: ComboboxRootProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare const ComboboxClearTrigger: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.ClearTriggerProps> & Combobox.ClearTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
48
|
+
export declare const ComboboxContent: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.ContentProps> & Combobox.ContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
|
+
export declare const ComboboxControl: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.ControlProps> & Combobox.ControlProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
50
|
+
export declare const ComboboxInput: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.InputProps> & Combobox.InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
51
|
+
export declare const ComboboxItemGroupLabel: ({ children, textStyle, fontWeight, ...props }: Combobox.ItemGroupLabelProps & TextProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare const ComboboxItemGroup: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.ItemGroupProps> & Combobox.ItemGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
53
|
+
export declare const ComboboxItemIndicator: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.ItemIndicatorProps> & Combobox.ItemIndicatorProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
54
|
+
export declare const ComboboxItem: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.ItemProps> & Combobox.ItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
55
|
+
export declare const ComboboxItemText: ({ textStyle, fontWeight, ...props }: Combobox.ItemTextProps & TextProps) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare const ComboboxLabel: ({ textStyle, fontWeight, ...props }: Combobox.LabelProps & TextProps) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export declare const ComboboxPositioner: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.PositionerProps> & Combobox.PositionerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
58
|
+
export declare const ComboboxTrigger: import("react").ForwardRefExoticComponent<Omit<JsxStyleProps, keyof Combobox.TriggerProps> & Combobox.TriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
59
|
+
export {};
|
package/lib/Combobox.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ComboboxTrigger = exports.ComboboxRoot = exports.ComboboxPositioner = exports.ComboboxLabel = exports.ComboboxItemText = exports.ComboboxItemIndicator = exports.ComboboxItemGroupLabel = exports.ComboboxItemGroup = exports.ComboboxItem = exports.ComboboxInput = exports.ComboboxControl = exports.ComboboxContent = exports.ComboboxClearTrigger = void 0;
|
|
7
|
+
var _react = require("@ark-ui/react");
|
|
8
|
+
var _css = require("@ndla/styled-system/css");
|
|
9
|
+
var _createStyleContext = require("./createStyleContext");
|
|
10
|
+
var _Label = require("./Label");
|
|
11
|
+
var _Text = require("./Text");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
/**
|
|
14
|
+
* Copyright (c) 2024-present, NDLA.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const comboboxRecipe = (0, _css.sva)({
|
|
22
|
+
slots: _react.comboboxAnatomy.keys(),
|
|
23
|
+
base: {
|
|
24
|
+
root: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
flexDirection: "column",
|
|
27
|
+
gap: "3xsmall"
|
|
28
|
+
},
|
|
29
|
+
control: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
gap: "4xsmall"
|
|
33
|
+
},
|
|
34
|
+
content: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
gap: "4xsmall",
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
zIndex: "dropdown",
|
|
39
|
+
background: "surface.default",
|
|
40
|
+
borderRadius: "xsmall",
|
|
41
|
+
boxShadow: "large",
|
|
42
|
+
padding: "xsmall",
|
|
43
|
+
overflowY: "auto",
|
|
44
|
+
maxHeight: "surface.xsmall",
|
|
45
|
+
_open: {
|
|
46
|
+
animation: "fade-shift-in 0.25s ease-out"
|
|
47
|
+
},
|
|
48
|
+
_closed: {
|
|
49
|
+
animation: "fade-shift-out 0.25s ease-out"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
item: {
|
|
53
|
+
display: "flex",
|
|
54
|
+
justifyContent: "space-between",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
cursor: "pointer",
|
|
57
|
+
borderRadius: "xsmall",
|
|
58
|
+
transitionDuration: "fast",
|
|
59
|
+
transitionProperty: "background, color, border-color",
|
|
60
|
+
transitionTimingFunction: "default",
|
|
61
|
+
background: "surface.default",
|
|
62
|
+
_disabled: {
|
|
63
|
+
cursor: "not-allowed",
|
|
64
|
+
background: "surface.disabled",
|
|
65
|
+
color: "text.disabled",
|
|
66
|
+
_hover: {
|
|
67
|
+
background: "surface.disabled",
|
|
68
|
+
color: "text.disabled"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
_hover: {
|
|
72
|
+
background: "surface.hover"
|
|
73
|
+
},
|
|
74
|
+
_highlighted: {
|
|
75
|
+
background: "surface.hover"
|
|
76
|
+
},
|
|
77
|
+
_checked: {
|
|
78
|
+
background: "surface.selected",
|
|
79
|
+
_highlighted: {
|
|
80
|
+
background: "surface.hover"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
trigger: {
|
|
85
|
+
"& svg": {
|
|
86
|
+
color: "icon.default",
|
|
87
|
+
transformOrigin: "center",
|
|
88
|
+
transitionDuration: "normal",
|
|
89
|
+
transitionProperty: "transform",
|
|
90
|
+
transitionTimingFunction: "default"
|
|
91
|
+
},
|
|
92
|
+
_open: {
|
|
93
|
+
"& svg": {
|
|
94
|
+
transform: "rotate(180deg)"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
itemIndicator: {
|
|
99
|
+
color: "stroke.default"
|
|
100
|
+
},
|
|
101
|
+
itemText: {
|
|
102
|
+
_checked: {
|
|
103
|
+
textDecoration: "underline"
|
|
104
|
+
},
|
|
105
|
+
_highlighted: {
|
|
106
|
+
textDecoration: "underline"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
itemGroup: {
|
|
110
|
+
display: "flex",
|
|
111
|
+
flexDirection: "column",
|
|
112
|
+
gap: "4xsmall"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
defaultVariants: {
|
|
116
|
+
variant: "simple"
|
|
117
|
+
},
|
|
118
|
+
variants: {
|
|
119
|
+
variant: {
|
|
120
|
+
simple: {
|
|
121
|
+
item: {
|
|
122
|
+
padding: "xsmall"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
bordered: {
|
|
126
|
+
item: {
|
|
127
|
+
paddingInline: "small",
|
|
128
|
+
paddingBlock: "xsmall",
|
|
129
|
+
border: "1px solid",
|
|
130
|
+
borderColor: "stroke.subtle",
|
|
131
|
+
_hover: {
|
|
132
|
+
borderColor: "stroke.hover",
|
|
133
|
+
background: "surface.default"
|
|
134
|
+
},
|
|
135
|
+
_highlighted: {
|
|
136
|
+
borderColor: "stroke.default"
|
|
137
|
+
},
|
|
138
|
+
_checked: {
|
|
139
|
+
borderColor: "stroke.default"
|
|
140
|
+
},
|
|
141
|
+
_disabled: {
|
|
142
|
+
borderColor: "stroke.disabled",
|
|
143
|
+
_hover: {
|
|
144
|
+
borderColor: "stroke.disabled"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const {
|
|
153
|
+
withProvider,
|
|
154
|
+
withContext
|
|
155
|
+
} = (0, _createStyleContext.createStyleContext)(comboboxRecipe);
|
|
156
|
+
const InternalComboboxRoot = withProvider(_react.Combobox.Root, "root");
|
|
157
|
+
const ComboboxRoot = _ref => {
|
|
158
|
+
let {
|
|
159
|
+
...props
|
|
160
|
+
} = _ref;
|
|
161
|
+
return (
|
|
162
|
+
/*#__PURE__*/
|
|
163
|
+
//@ts-expect-error - withProvider swallows the generic that Combobox.Root expects.
|
|
164
|
+
(0, _jsxRuntime.jsx)(InternalComboboxRoot, {
|
|
165
|
+
...props
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
exports.ComboboxRoot = ComboboxRoot;
|
|
170
|
+
const ComboboxClearTrigger = exports.ComboboxClearTrigger = withContext(_react.Combobox.ClearTrigger, "clearTrigger");
|
|
171
|
+
const ComboboxContent = exports.ComboboxContent = withContext(_react.Combobox.Content, "content");
|
|
172
|
+
const ComboboxControl = exports.ComboboxControl = withContext(_react.Combobox.Control, "control");
|
|
173
|
+
const ComboboxInput = exports.ComboboxInput = withContext(_react.Combobox.Input, "input");
|
|
174
|
+
const InternalComboboxItemGroupLabel = withContext(_react.Combobox.ItemGroupLabel, "itemGroupLabel");
|
|
175
|
+
const ComboboxItemGroupLabel = _ref2 => {
|
|
176
|
+
let {
|
|
177
|
+
children,
|
|
178
|
+
textStyle = "label.small",
|
|
179
|
+
fontWeight = "bold",
|
|
180
|
+
...props
|
|
181
|
+
} = _ref2;
|
|
182
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalComboboxItemGroupLabel, {
|
|
183
|
+
forwardCssProp: true,
|
|
184
|
+
asChild: true,
|
|
185
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
186
|
+
asChild: true,
|
|
187
|
+
forwardCssProp: true,
|
|
188
|
+
textStyle: textStyle,
|
|
189
|
+
fontWeight: fontWeight,
|
|
190
|
+
...props,
|
|
191
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
192
|
+
children: children
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
exports.ComboboxItemGroupLabel = ComboboxItemGroupLabel;
|
|
198
|
+
const ComboboxItemGroup = exports.ComboboxItemGroup = withContext(_react.Combobox.ItemGroup, "itemGroup");
|
|
199
|
+
const ComboboxItemIndicator = exports.ComboboxItemIndicator = withContext(_react.Combobox.ItemIndicator, "itemIndicator");
|
|
200
|
+
const ComboboxItem = exports.ComboboxItem = withContext(_react.Combobox.Item, "item");
|
|
201
|
+
const InternalComboboxItemText = withContext(_react.Combobox.ItemText, "itemText");
|
|
202
|
+
const ComboboxItemText = _ref3 => {
|
|
203
|
+
let {
|
|
204
|
+
textStyle = "label.medium",
|
|
205
|
+
fontWeight = "bold",
|
|
206
|
+
...props
|
|
207
|
+
} = _ref3;
|
|
208
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalComboboxItemText, {
|
|
209
|
+
forwardCssProp: true,
|
|
210
|
+
asChild: true,
|
|
211
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
212
|
+
...props
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
exports.ComboboxItemText = ComboboxItemText;
|
|
217
|
+
const InternalComboboxLabel = withContext(_react.Combobox.Label, "label");
|
|
218
|
+
const ComboboxLabel = _ref4 => {
|
|
219
|
+
let {
|
|
220
|
+
textStyle = "label.medium",
|
|
221
|
+
fontWeight = "bold",
|
|
222
|
+
...props
|
|
223
|
+
} = _ref4;
|
|
224
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalComboboxLabel, {
|
|
225
|
+
forwardCssProp: true,
|
|
226
|
+
asChild: true,
|
|
227
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Label.Label, {
|
|
228
|
+
textStyle: textStyle,
|
|
229
|
+
fontWeight: fontWeight,
|
|
230
|
+
...props
|
|
231
|
+
})
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
exports.ComboboxLabel = ComboboxLabel;
|
|
235
|
+
const ComboboxPositioner = exports.ComboboxPositioner = withContext(_react.Combobox.Positioner, "positioner");
|
|
236
|
+
const ComboboxTrigger = exports.ComboboxTrigger = withContext(_react.Combobox.Trigger, "trigger");
|