@obosbbl/grunnmuren-react 2.0.0-canary.1 → 2.0.0-canary.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/README.md +73 -1
- package/dist/Button-client-XmGlKEk4.js +143 -0
- package/dist/index.d.mts +397 -0
- package/dist/index.mjs +537 -0
- package/package.json +8 -38
- package/dist/button/Button.d.mts +0 -83
- package/dist/button/Button.d.ts +0 -83
- package/dist/button/Button.mjs +0 -149
- package/dist/checkbox/index.d.mts +0 -32
- package/dist/checkbox/index.d.ts +0 -32
- package/dist/checkbox/index.mjs +0 -106
- package/dist/label/index.d.mts +0 -13
- package/dist/label/index.d.ts +0 -13
- package/dist/label/index.mjs +0 -45
- package/dist/radiogroup/index.d.mts +0 -30
- package/dist/radiogroup/index.d.ts +0 -30
- package/dist/radiogroup/index.mjs +0 -65
- package/dist/textfield/index.d.mts +0 -31
- package/dist/textfield/index.d.ts +0 -31
- package/dist/textfield/index.mjs +0 -88
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import { Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1, FieldError, ListBoxItem, ComboBox, Group, Input, Button, Popover, ListBox, RadioGroup as RadioGroup$1, Radio as Radio$1, Select as Select$1, SelectValue, TextField as TextField$1, TextArea as TextArea$1, NumberField as NumberField$1 } from 'react-aria-components';
|
|
2
|
+
export { Form, I18nProvider } from 'react-aria-components';
|
|
3
|
+
export { _ as Button } from './Button-client-XmGlKEk4.js';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { forwardRef, useId } from 'react';
|
|
6
|
+
import { cx, cva, compose } from 'cva';
|
|
7
|
+
import { Check, LoadingSpinner, ChevronDown } from '@obosbbl/grunnmuren-icons-react';
|
|
8
|
+
|
|
9
|
+
const formField = cx('group flex flex-col gap-2');
|
|
10
|
+
const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-sm leading-6 text-red');
|
|
11
|
+
const input = cva({
|
|
12
|
+
base: [
|
|
13
|
+
'rounded-md px-3 py-2.5 text-sm font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
|
|
14
|
+
// invalid styles
|
|
15
|
+
'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red',
|
|
16
|
+
// Fix invisible ring on safari: https://github.com/tailwindlabs/tailwindcss.com/issues/1135
|
|
17
|
+
'appearance-none'
|
|
18
|
+
],
|
|
19
|
+
variants: {
|
|
20
|
+
// Focus rings. Can either be :focus or :focus-visible based on the needs of the particular component.
|
|
21
|
+
focusModifier: {
|
|
22
|
+
focus: 'focus:ring-2 group-data-[invalid]:focus:ring',
|
|
23
|
+
visible: 'data-[focus-visible]:ring-2 group-data-[invalid]:data-[focus-visible]:ring'
|
|
24
|
+
},
|
|
25
|
+
isGrouped: {
|
|
26
|
+
false: '',
|
|
27
|
+
//
|
|
28
|
+
true: 'flex-1 !ring-0 first:pl-0 last:pr-0'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
focusModifier: 'focus',
|
|
33
|
+
isGrouped: false
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const inputGroup = cx('inline-flex items-center overflow-hidden rounded-md px-3 ring-1 ring-black focus-within:ring-2 group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring');
|
|
37
|
+
const dropdown = {
|
|
38
|
+
popover: cx('min-w-[--trigger-width] overflow-auto rounded-md border border-black bg-white shadow data-[entering]:animate-in data-[exiting]:animate-out data-[entering]:fade-in data-[exiting]:fade-out'),
|
|
39
|
+
listbox: cx('text-sm outline-none'),
|
|
40
|
+
chevronIcon: cx('text-base transition-transform duration-150 group-data-[open]:rotate-180 motion-reduce:transition-none')
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function ErrorMessage(props) {
|
|
44
|
+
const { children, className, ...restProps } = props;
|
|
45
|
+
return /*#__PURE__*/ jsx(Text, {
|
|
46
|
+
...restProps,
|
|
47
|
+
className: cx(className, formFieldError),
|
|
48
|
+
slot: "errorMessage",
|
|
49
|
+
children: children
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function Description(props) {
|
|
54
|
+
const { className, ...restProps } = props;
|
|
55
|
+
return /*#__PURE__*/ jsx(Text, {
|
|
56
|
+
...restProps,
|
|
57
|
+
className: cx(className, 'text-sm font-light leading-6'),
|
|
58
|
+
slot: "description"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const defaultClasses$1 = cx([
|
|
63
|
+
'group relative left-0 inline-flex max-w-fit cursor-pointer items-start gap-4 py-2 leading-7'
|
|
64
|
+
]);
|
|
65
|
+
// Pulling this out into it's own component. Will probably export it in the future
|
|
66
|
+
// so it can be used in other views, outside of an input of type checkbox, like in table rows.
|
|
67
|
+
function CheckmarkBox() {
|
|
68
|
+
return /*#__PURE__*/ jsx("span", {
|
|
69
|
+
className: cx([
|
|
70
|
+
'relative left-0 grid flex-none place-content-center rounded-sm border-2 border-black text-white',
|
|
71
|
+
// to vertically align the radio we need to calculate the label's height, which is equal to it's font size multiplied by the line height.
|
|
72
|
+
// For the ::before psuedo element the line height of the label is always 1em.
|
|
73
|
+
// When we know the height of the label we use the height of the radio to push it down to align with the label's first line
|
|
74
|
+
// TODO: 1.75 here is the unit less lineheight, altough we use 1.75rem as the line height, so there is a mismatch here. Revisit this when we've worked on typography in v2. Should this be a CSS custom property instead?
|
|
75
|
+
'mt-[calc((1em_*_1.75_-_24px)_/_2)] h-[24px] w-[24px]',
|
|
76
|
+
// selected
|
|
77
|
+
'group-data-[selected]:!border-green group-data-[selected]:!bg-green',
|
|
78
|
+
// focus
|
|
79
|
+
'group-data-[focus-visible]:ring-2 group-data-[focus-visible]:ring-black group-data-[focus-visible]:ring-offset-[9px]',
|
|
80
|
+
// hovered
|
|
81
|
+
'group-data-[hovered]:border-green group-data-[hovered]:group-data-[invalid]:border-red group-data-[hovered]:bg-green-lightest group-data-[hovered]:group-data-[invalid]:bg-red-light',
|
|
82
|
+
// invalid - The border is 1 px thicker when invalid. We don't actually want to change the border width, as that causes the element's size to change
|
|
83
|
+
// so we use an inner shadow of 1 px instead to pad the actual border
|
|
84
|
+
'group-data-[invalid]:border-red group-data-[invalid]:group-data-[selected]:shadow-none group-data-[invalid]:shadow-[inset_0_0_0_1px] group-data-[invalid]:shadow-red'
|
|
85
|
+
]),
|
|
86
|
+
children: /*#__PURE__*/ jsx(Check, {
|
|
87
|
+
className: "h-full w-full opacity-0 group-data-[selected]:opacity-100"
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function Checkbox(props, ref) {
|
|
92
|
+
const { children, className, description, errorMessage, isInvalid: _isInvalid, ...restProps } = props;
|
|
93
|
+
const id = useId();
|
|
94
|
+
const descriptionId = 'desc' + id;
|
|
95
|
+
const errorMessageId = 'error' + id;
|
|
96
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
97
|
+
return /*#__PURE__*/ jsx("div", {
|
|
98
|
+
children: /*#__PURE__*/ jsxs(CheckboxContext.Provider, {
|
|
99
|
+
value: {
|
|
100
|
+
'aria-describedby': description ? descriptionId : undefined,
|
|
101
|
+
'aria-errormessage': errorMessage ? errorMessageId : undefined
|
|
102
|
+
},
|
|
103
|
+
children: [
|
|
104
|
+
/*#__PURE__*/ jsxs(Checkbox$1, {
|
|
105
|
+
...restProps,
|
|
106
|
+
className: cx(className, defaultClasses$1),
|
|
107
|
+
isInvalid: isInvalid,
|
|
108
|
+
ref: ref,
|
|
109
|
+
children: [
|
|
110
|
+
/*#__PURE__*/ jsx("span", {
|
|
111
|
+
className: "absolute -left-2.5 top-0 z-10 h-11 w-11"
|
|
112
|
+
}),
|
|
113
|
+
/*#__PURE__*/ jsx(CheckmarkBox, {}),
|
|
114
|
+
children
|
|
115
|
+
]
|
|
116
|
+
}),
|
|
117
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
118
|
+
className: "block",
|
|
119
|
+
id: descriptionId,
|
|
120
|
+
children: description
|
|
121
|
+
}),
|
|
122
|
+
errorMessage && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
123
|
+
className: "mt-2 block",
|
|
124
|
+
id: errorMessageId,
|
|
125
|
+
children: errorMessage
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const _Checkbox = /*#__PURE__*/ forwardRef(Checkbox);
|
|
132
|
+
|
|
133
|
+
function Label(props) {
|
|
134
|
+
const { children, className, ...restProps } = props;
|
|
135
|
+
return /*#__PURE__*/ jsx(Label$1, {
|
|
136
|
+
className: cx(className, 'font-semibold leading-7'),
|
|
137
|
+
...restProps,
|
|
138
|
+
children: children
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function CheckboxGroup(props, ref) {
|
|
143
|
+
const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
|
|
144
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
145
|
+
return /*#__PURE__*/ jsxs(CheckboxGroup$1, {
|
|
146
|
+
...restProps,
|
|
147
|
+
className: cx(className, 'flex flex-col gap-2'),
|
|
148
|
+
isInvalid: isInvalid,
|
|
149
|
+
isRequired: isRequired,
|
|
150
|
+
ref: ref,
|
|
151
|
+
children: [
|
|
152
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
153
|
+
children: label
|
|
154
|
+
}),
|
|
155
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
156
|
+
children: description
|
|
157
|
+
}),
|
|
158
|
+
children,
|
|
159
|
+
errorMessage && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
160
|
+
children: errorMessage
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const _CheckboxGroup = /*#__PURE__*/ forwardRef(CheckboxGroup);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* This component handles renders a custom error message (if provided), otherwise it falls back to the browser's native validation.
|
|
169
|
+
* In other words, this handles controlled and uncontrolled form errors.
|
|
170
|
+
*/ function ErrorMessageOrFieldError({ errorMessage }) {
|
|
171
|
+
return errorMessage ? /*#__PURE__*/ jsx(ErrorMessage, {
|
|
172
|
+
children: errorMessage
|
|
173
|
+
}) : /*#__PURE__*/ jsx(FieldError, {
|
|
174
|
+
className: formFieldError
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function Combobox(props, ref) {
|
|
179
|
+
const { className, children, description, errorMessage, isLoading, label, isInvalid: _isInvalid, ...restProps } = props;
|
|
180
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
181
|
+
return /*#__PURE__*/ jsxs(ComboBox, {
|
|
182
|
+
...restProps,
|
|
183
|
+
className: cx(className, formField),
|
|
184
|
+
isInvalid: isInvalid,
|
|
185
|
+
children: [
|
|
186
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
187
|
+
children: label
|
|
188
|
+
}),
|
|
189
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
190
|
+
children: description
|
|
191
|
+
}),
|
|
192
|
+
/*#__PURE__*/ jsxs(Group, {
|
|
193
|
+
className: inputGroup,
|
|
194
|
+
children: [
|
|
195
|
+
/*#__PURE__*/ jsx(Input, {
|
|
196
|
+
className: input({
|
|
197
|
+
isGrouped: true
|
|
198
|
+
}),
|
|
199
|
+
ref: ref
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ jsx(Button, {
|
|
202
|
+
children: isLoading ? /*#__PURE__*/ jsx(LoadingSpinner, {
|
|
203
|
+
className: "animate-spin"
|
|
204
|
+
}) : /*#__PURE__*/ jsx(ChevronDown, {
|
|
205
|
+
className: dropdown.chevronIcon
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
}),
|
|
210
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
211
|
+
errorMessage: errorMessage
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ jsx(Popover, {
|
|
214
|
+
// FIXME: The trigger width doesn't include the padding of the group, so for now we have to apply this workaround.
|
|
215
|
+
// Also... the combobox border gets a pixel wider when focused, so we account for that as well when calculating the width
|
|
216
|
+
// and the offset.
|
|
217
|
+
// The input gutter should probably be moved to a theme variable instead of using the hardcoded value as here.
|
|
218
|
+
className: cx(dropdown.popover, 'min-w-[calc(var(--trigger-width)+26px)]'),
|
|
219
|
+
crossOffset: -13,
|
|
220
|
+
children: /*#__PURE__*/ jsx(ListBox, {
|
|
221
|
+
className: dropdown.listbox,
|
|
222
|
+
children: children
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const ComboboxItem = (props)=>{
|
|
229
|
+
let textValue = props.textValue;
|
|
230
|
+
// When the ListBoxItem child isn't a string we have to set textValue for keyboard completion to work.
|
|
231
|
+
// Since we use a render function (to handle the selected state) the child is never a string.
|
|
232
|
+
// This condition adds back that behaviour
|
|
233
|
+
if (textValue == null && typeof props.children === 'string') {
|
|
234
|
+
textValue = props.children;
|
|
235
|
+
}
|
|
236
|
+
return /*#__PURE__*/ jsx(ListBoxItem, {
|
|
237
|
+
...props,
|
|
238
|
+
className: cx(props.className, 'flex cursor-default px-6 py-2 leading-6 outline-none data-[focused]:bg-sky-lightest'),
|
|
239
|
+
textValue: textValue,
|
|
240
|
+
children: ({ isSelected })=>/*#__PURE__*/ jsxs(Fragment, {
|
|
241
|
+
children: [
|
|
242
|
+
isSelected && /*#__PURE__*/ jsx(Check, {
|
|
243
|
+
className: "-ml-6 text-base"
|
|
244
|
+
}),
|
|
245
|
+
props.children
|
|
246
|
+
]
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
const _Combobox = /*#__PURE__*/ forwardRef(Combobox);
|
|
251
|
+
|
|
252
|
+
function RadioGroup(props, ref) {
|
|
253
|
+
const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
|
|
254
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
255
|
+
return /*#__PURE__*/ jsxs(RadioGroup$1, {
|
|
256
|
+
...restProps,
|
|
257
|
+
className: cx(className, 'flex flex-col gap-2'),
|
|
258
|
+
isInvalid: isInvalid,
|
|
259
|
+
isRequired: isRequired,
|
|
260
|
+
ref: ref,
|
|
261
|
+
children: [
|
|
262
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
263
|
+
children: label
|
|
264
|
+
}),
|
|
265
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
266
|
+
children: description
|
|
267
|
+
}),
|
|
268
|
+
children,
|
|
269
|
+
errorMessage && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
270
|
+
children: errorMessage
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const _RadioGroup = /*#__PURE__*/ forwardRef(RadioGroup);
|
|
276
|
+
|
|
277
|
+
const defaultClasses = cx([
|
|
278
|
+
'relative inline-flex max-w-fit cursor-pointer items-start gap-4 py-2 leading-7',
|
|
279
|
+
// the radio button itself
|
|
280
|
+
'before:flex-none before:rounded-full before:border-2 before:border-black',
|
|
281
|
+
// to vertically align the radio we need to calculate the label's height, which is equal to it's font size multiplied by the line height.
|
|
282
|
+
// For the ::before psuedo element the line height of the label is always 1em.
|
|
283
|
+
// When we know the height of the label we use the height of the radio to push it down to align with the label's first line
|
|
284
|
+
// TODO: 1.75 here is the unit less lineheight, altough we use 1.75rem as the line height, so there is a mismatch here. Revisit this when we've worked on typography in v2. Should this be a CSS custom property instead?
|
|
285
|
+
'before:mt-[calc((1em_*_1.75_-_24px)_/_2)] before:h-[24px] before:w-[24px]',
|
|
286
|
+
// selected
|
|
287
|
+
'data-[selected]:before:border-black data-[selected]:before:bg-green data-[selected]:before:shadow-[inset_0_0_0_4px_rgb(255,255,255)]',
|
|
288
|
+
// hover
|
|
289
|
+
'data-[hovered]:before:border-green data-[hovered]:before:bg-green-lightest data-[hovered]:data-[invalid]:before:bg-red-light',
|
|
290
|
+
// focus
|
|
291
|
+
'data-[focus-visible]:before:ring data-[focus-visible]:before:ring-black data-[focus-visible]:before:ring-offset-[9px]',
|
|
292
|
+
// invalid - The border is 1 px thicker when invalid. We don't actually want to change the border width, as that causes the element's size to change
|
|
293
|
+
// so we use an inner outline to artifically pad the border
|
|
294
|
+
'data-[invalid]:before:outline-solid data-[invalid]:before:border-red data-[invalid]:data-[selected]:before:!bg-red data-[invalid]:before:outline data-[invalid]:before:outline-[3px] data-[invalid]:before:outline-offset-[-3px] data-[invalid]:before:outline-red'
|
|
295
|
+
]);
|
|
296
|
+
function Radio(props, ref) {
|
|
297
|
+
const { children, className, description, ...restProps } = props;
|
|
298
|
+
return /*#__PURE__*/ jsxs(Radio$1, {
|
|
299
|
+
...restProps,
|
|
300
|
+
className: cx(className, defaultClasses),
|
|
301
|
+
ref: ref,
|
|
302
|
+
children: [
|
|
303
|
+
/*#__PURE__*/ jsx("span", {
|
|
304
|
+
className: "absolute -left-2.5 top-0 z-10 h-11 w-11 "
|
|
305
|
+
}),
|
|
306
|
+
/*#__PURE__*/ jsxs("div", {
|
|
307
|
+
children: [
|
|
308
|
+
children,
|
|
309
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
310
|
+
className: "mt-2 block",
|
|
311
|
+
children: description
|
|
312
|
+
})
|
|
313
|
+
]
|
|
314
|
+
})
|
|
315
|
+
]
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
const _Radio = /*#__PURE__*/ forwardRef(Radio);
|
|
319
|
+
|
|
320
|
+
function Select(props, ref) {
|
|
321
|
+
const { className, children, description, errorMessage, label, isInvalid: _isInvalid, ...restProps } = props;
|
|
322
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
323
|
+
return /*#__PURE__*/ jsxs(Select$1, {
|
|
324
|
+
...restProps,
|
|
325
|
+
className: cx(className, formField),
|
|
326
|
+
isInvalid: isInvalid,
|
|
327
|
+
children: [
|
|
328
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
329
|
+
children: label
|
|
330
|
+
}),
|
|
331
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
332
|
+
children: description
|
|
333
|
+
}),
|
|
334
|
+
/*#__PURE__*/ jsxs(Button, {
|
|
335
|
+
className: cx(input({
|
|
336
|
+
focusModifier: 'visible'
|
|
337
|
+
}), // How to reuse placeholder text?
|
|
338
|
+
'inline-flex cursor-default items-center gap-2'),
|
|
339
|
+
// See https://github.com/adobe/react-spectrum/discussions/4792#discussioncomment-6492305
|
|
340
|
+
ref: ref,
|
|
341
|
+
children: [
|
|
342
|
+
/*#__PURE__*/ jsx(SelectValue, {
|
|
343
|
+
className: "flex-1 truncate text-left data-[placeholder]:text-[#727070]"
|
|
344
|
+
}),
|
|
345
|
+
/*#__PURE__*/ jsx(ChevronDown, {
|
|
346
|
+
className: dropdown.chevronIcon
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
}),
|
|
350
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
351
|
+
errorMessage: errorMessage
|
|
352
|
+
}),
|
|
353
|
+
/*#__PURE__*/ jsx(Popover, {
|
|
354
|
+
className: dropdown.popover,
|
|
355
|
+
children: /*#__PURE__*/ jsx(ListBox, {
|
|
356
|
+
className: dropdown.listbox,
|
|
357
|
+
children: children
|
|
358
|
+
})
|
|
359
|
+
})
|
|
360
|
+
]
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
const SelectItem = (props)=>{
|
|
364
|
+
let textValue = props.textValue;
|
|
365
|
+
// When the ListBoxItem child isn't a string we have to set textValue for keyboard completion to work.
|
|
366
|
+
// Since we use a render function (to handle the selected state) the child is never a string.
|
|
367
|
+
// This condition adds back that behaviour
|
|
368
|
+
if (textValue == null && typeof props.children === 'string') {
|
|
369
|
+
textValue = props.children;
|
|
370
|
+
}
|
|
371
|
+
return /*#__PURE__*/ jsx(ListBoxItem, {
|
|
372
|
+
...props,
|
|
373
|
+
className: cx(props.className, 'flex cursor-default px-6 py-2 leading-6 outline-none data-[focused]:bg-sky-lightest'),
|
|
374
|
+
textValue: textValue,
|
|
375
|
+
children: ({ isSelected })=>/*#__PURE__*/ jsxs(Fragment, {
|
|
376
|
+
children: [
|
|
377
|
+
isSelected && /*#__PURE__*/ jsx(Check, {
|
|
378
|
+
className: "-ml-6 text-base"
|
|
379
|
+
}),
|
|
380
|
+
props.children
|
|
381
|
+
]
|
|
382
|
+
})
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
const _Select = /*#__PURE__*/ forwardRef(Select);
|
|
386
|
+
|
|
387
|
+
function TextArea(props, ref) {
|
|
388
|
+
const { className, description, errorMessage, label, isInvalid: _isInvalid, rows, ...restProps } = props;
|
|
389
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
390
|
+
return /*#__PURE__*/ jsxs(TextField$1, {
|
|
391
|
+
...restProps,
|
|
392
|
+
className: cx(className, formField),
|
|
393
|
+
isInvalid: isInvalid,
|
|
394
|
+
children: [
|
|
395
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
396
|
+
children: label
|
|
397
|
+
}),
|
|
398
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
399
|
+
children: description
|
|
400
|
+
}),
|
|
401
|
+
/*#__PURE__*/ jsx(TextArea$1, {
|
|
402
|
+
className: input(),
|
|
403
|
+
rows: rows,
|
|
404
|
+
ref: ref
|
|
405
|
+
}),
|
|
406
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
407
|
+
errorMessage: errorMessage
|
|
408
|
+
})
|
|
409
|
+
]
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
const _TextArea = /*#__PURE__*/ forwardRef(TextArea);
|
|
413
|
+
|
|
414
|
+
const inputWithAlignment$1 = compose(input, cva({
|
|
415
|
+
base: '',
|
|
416
|
+
variants: {
|
|
417
|
+
textAlign: {
|
|
418
|
+
right: 'text-right',
|
|
419
|
+
left: ''
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}));
|
|
423
|
+
function TextField(props, ref) {
|
|
424
|
+
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
|
|
425
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
426
|
+
return /*#__PURE__*/ jsxs(TextField$1, {
|
|
427
|
+
...restProps,
|
|
428
|
+
className: cx(className, formField),
|
|
429
|
+
isInvalid: isInvalid,
|
|
430
|
+
children: [
|
|
431
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
432
|
+
children: label
|
|
433
|
+
}),
|
|
434
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
435
|
+
children: description
|
|
436
|
+
}),
|
|
437
|
+
leftAddon || rightAddon ? /*#__PURE__*/ jsxs(Group, {
|
|
438
|
+
className: inputGroup,
|
|
439
|
+
children: [
|
|
440
|
+
leftAddon,
|
|
441
|
+
withAddonDivider && leftAddon && /*#__PURE__*/ jsx(Divider$1, {
|
|
442
|
+
className: "ml-3"
|
|
443
|
+
}),
|
|
444
|
+
/*#__PURE__*/ jsx(Input, {
|
|
445
|
+
className: inputWithAlignment$1({
|
|
446
|
+
textAlign,
|
|
447
|
+
isGrouped: true
|
|
448
|
+
}),
|
|
449
|
+
ref: ref
|
|
450
|
+
}),
|
|
451
|
+
withAddonDivider && rightAddon && /*#__PURE__*/ jsx(Divider$1, {
|
|
452
|
+
className: "mr-3"
|
|
453
|
+
}),
|
|
454
|
+
rightAddon
|
|
455
|
+
]
|
|
456
|
+
}) : /*#__PURE__*/ jsx(Input, {
|
|
457
|
+
className: inputWithAlignment$1({
|
|
458
|
+
textAlign
|
|
459
|
+
}),
|
|
460
|
+
ref: ref
|
|
461
|
+
}),
|
|
462
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
463
|
+
errorMessage: errorMessage
|
|
464
|
+
})
|
|
465
|
+
]
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
function Divider$1({ className }) {
|
|
469
|
+
return /*#__PURE__*/ jsx("span", {
|
|
470
|
+
className: cx(className, 'block h-6 w-px flex-none bg-black')
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
const _TextField = /*#__PURE__*/ forwardRef(TextField);
|
|
474
|
+
|
|
475
|
+
// This component is based on a copy of ../textfield/TextField, refactoring is TBD: https://github.com/code-obos/grunnmuren/pull/722#issuecomment-1931478786
|
|
476
|
+
const inputWithAlignment = compose(input, cva({
|
|
477
|
+
base: '',
|
|
478
|
+
variants: {
|
|
479
|
+
textAlign: {
|
|
480
|
+
right: 'text-right',
|
|
481
|
+
left: ''
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}));
|
|
485
|
+
function NumberField(props, ref) {
|
|
486
|
+
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
|
|
487
|
+
const isInvalid = _isInvalid || errorMessage != null;
|
|
488
|
+
return /*#__PURE__*/ jsxs(NumberField$1, {
|
|
489
|
+
...restProps,
|
|
490
|
+
className: cx(className, formField),
|
|
491
|
+
isInvalid: isInvalid,
|
|
492
|
+
children: [
|
|
493
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
494
|
+
children: label
|
|
495
|
+
}),
|
|
496
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
497
|
+
children: description
|
|
498
|
+
}),
|
|
499
|
+
leftAddon || rightAddon ? /*#__PURE__*/ jsxs(Group, {
|
|
500
|
+
className: inputGroup,
|
|
501
|
+
children: [
|
|
502
|
+
leftAddon,
|
|
503
|
+
withAddonDivider && leftAddon && /*#__PURE__*/ jsx(Divider, {
|
|
504
|
+
className: "ml-3"
|
|
505
|
+
}),
|
|
506
|
+
/*#__PURE__*/ jsx(Input, {
|
|
507
|
+
className: inputWithAlignment({
|
|
508
|
+
textAlign,
|
|
509
|
+
isGrouped: true
|
|
510
|
+
}),
|
|
511
|
+
ref: ref
|
|
512
|
+
}),
|
|
513
|
+
withAddonDivider && rightAddon && /*#__PURE__*/ jsx(Divider, {
|
|
514
|
+
className: "mr-3"
|
|
515
|
+
}),
|
|
516
|
+
rightAddon
|
|
517
|
+
]
|
|
518
|
+
}) : /*#__PURE__*/ jsx(Input, {
|
|
519
|
+
className: inputWithAlignment({
|
|
520
|
+
textAlign
|
|
521
|
+
}),
|
|
522
|
+
ref: ref
|
|
523
|
+
}),
|
|
524
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
525
|
+
errorMessage: errorMessage
|
|
526
|
+
})
|
|
527
|
+
]
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function Divider({ className }) {
|
|
531
|
+
return /*#__PURE__*/ jsx("span", {
|
|
532
|
+
className: cx(className, 'block h-6 w-px flex-none bg-black')
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
const _NumberField = /*#__PURE__*/ forwardRef(NumberField);
|
|
536
|
+
|
|
537
|
+
export { _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ComboboxItem, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, SelectItem, _TextArea as TextArea, _TextField as TextField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obosbbl/grunnmuren-react",
|
|
3
|
-
"version": "2.0.0-canary.
|
|
3
|
+
"version": "2.0.0-canary.10",
|
|
4
4
|
"description": "Grunnmuren components in React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/code-obos/grunnmuren"
|
|
@@ -9,54 +9,24 @@
|
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
|
-
"
|
|
13
|
-
"types": "./dist/
|
|
14
|
-
"default": "./dist/
|
|
15
|
-
},
|
|
16
|
-
"./checkbox": {
|
|
17
|
-
"types": "./dist/checkbox/index.d.ts",
|
|
18
|
-
"default": "./dist/checkbox/index.mjs"
|
|
19
|
-
},
|
|
20
|
-
"./label": {
|
|
21
|
-
"types": "./dist/label/index.d.ts",
|
|
22
|
-
"default": "./dist/label/index.mjs"
|
|
23
|
-
},
|
|
24
|
-
"./radiogroup": {
|
|
25
|
-
"types": "./dist/radiogroup/index.d.ts",
|
|
26
|
-
"default": "./dist/radiogroup/index.mjs"
|
|
27
|
-
},
|
|
28
|
-
"./textfield": {
|
|
29
|
-
"types": "./dist/textfield/index.d.ts",
|
|
30
|
-
"default": "./dist/textfield/index.mjs"
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
31
15
|
}
|
|
32
16
|
},
|
|
33
17
|
"files": [
|
|
34
18
|
"dist"
|
|
35
19
|
],
|
|
36
20
|
"dependencies": {
|
|
37
|
-
"@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.
|
|
21
|
+
"@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.1",
|
|
22
|
+
"@react-aria/utils": "^3.23.0",
|
|
38
23
|
"cva": "1.0.0-beta.1",
|
|
39
|
-
"react-aria-components": "1.0.0
|
|
24
|
+
"react-aria-components": "^1.0.0"
|
|
40
25
|
},
|
|
41
26
|
"peerDependencies": {
|
|
42
27
|
"react": "^18"
|
|
43
28
|
},
|
|
44
|
-
"unbuild": {
|
|
45
|
-
"entries": [
|
|
46
|
-
"./src/button/Button.tsx",
|
|
47
|
-
"./src/checkbox/index.ts",
|
|
48
|
-
"./src/label/index.ts",
|
|
49
|
-
"./src/radiogroup/index.ts",
|
|
50
|
-
"./src/textfield/index.ts"
|
|
51
|
-
],
|
|
52
|
-
"declaration": true,
|
|
53
|
-
"rollup": {
|
|
54
|
-
"esbuild": {
|
|
55
|
-
"jsx": "automatic"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
29
|
"scripts": {
|
|
60
|
-
"build": "
|
|
30
|
+
"build": "bunchee"
|
|
61
31
|
}
|
|
62
32
|
}
|
package/dist/button/Button.d.mts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { VariantProps } from 'cva';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Figma: https://www.figma.com/file/9OvSg0ZXI5E1eQYi7AWiWn/Grunnmuren-2.0-%E2%94%82-Designsystem?node-id=30%3A2574&mode=dev
|
|
6
|
-
*/
|
|
7
|
-
declare const buttonVariants: (props?: ({
|
|
8
|
-
variant?: "primary" | "secondary" | "tertiary" | undefined;
|
|
9
|
-
color?: "green" | "mint" | "white" | undefined;
|
|
10
|
-
isIconOnly?: boolean | undefined;
|
|
11
|
-
} & ({
|
|
12
|
-
class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | {
|
|
13
|
-
[x: string]: any;
|
|
14
|
-
} | null | undefined)[] | {
|
|
15
|
-
[x: string]: any;
|
|
16
|
-
} | null | undefined)[] | {
|
|
17
|
-
[x: string]: any;
|
|
18
|
-
} | null | undefined)[] | {
|
|
19
|
-
[x: string]: any;
|
|
20
|
-
} | null | undefined)[] | {
|
|
21
|
-
[x: string]: any;
|
|
22
|
-
} | null | undefined)[] | {
|
|
23
|
-
[x: string]: any;
|
|
24
|
-
} | null | undefined)[] | {
|
|
25
|
-
[x: string]: any;
|
|
26
|
-
} | null | undefined)[] | {
|
|
27
|
-
[x: string]: any;
|
|
28
|
-
} | null | undefined)[] | {
|
|
29
|
-
[x: string]: any;
|
|
30
|
-
} | null | undefined)[] | {
|
|
31
|
-
[x: string]: any;
|
|
32
|
-
} | null | undefined)[] | {
|
|
33
|
-
[x: string]: any;
|
|
34
|
-
} | null | undefined)[] | {
|
|
35
|
-
[x: string]: any;
|
|
36
|
-
} | null | undefined;
|
|
37
|
-
className?: undefined;
|
|
38
|
-
} | {
|
|
39
|
-
class?: undefined;
|
|
40
|
-
className?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | {
|
|
41
|
-
[x: string]: any;
|
|
42
|
-
} | null | undefined)[] | {
|
|
43
|
-
[x: string]: any;
|
|
44
|
-
} | null | undefined)[] | {
|
|
45
|
-
[x: string]: any;
|
|
46
|
-
} | null | undefined)[] | {
|
|
47
|
-
[x: string]: any;
|
|
48
|
-
} | null | undefined)[] | {
|
|
49
|
-
[x: string]: any;
|
|
50
|
-
} | null | undefined)[] | {
|
|
51
|
-
[x: string]: any;
|
|
52
|
-
} | null | undefined)[] | {
|
|
53
|
-
[x: string]: any;
|
|
54
|
-
} | null | undefined)[] | {
|
|
55
|
-
[x: string]: any;
|
|
56
|
-
} | null | undefined)[] | {
|
|
57
|
-
[x: string]: any;
|
|
58
|
-
} | null | undefined)[] | {
|
|
59
|
-
[x: string]: any;
|
|
60
|
-
} | null | undefined)[] | {
|
|
61
|
-
[x: string]: any;
|
|
62
|
-
} | null | undefined)[] | {
|
|
63
|
-
[x: string]: any;
|
|
64
|
-
} | null | undefined;
|
|
65
|
-
})) | undefined) => string;
|
|
66
|
-
type ButtonOrLinkProps = (React.ComponentPropsWithoutRef<'button'> & {
|
|
67
|
-
href?: never;
|
|
68
|
-
}) | (React.ComponentPropsWithoutRef<'a'> & {
|
|
69
|
-
href: string;
|
|
70
|
-
});
|
|
71
|
-
type ButtonProps = VariantProps<typeof buttonVariants> & {
|
|
72
|
-
className?: string;
|
|
73
|
-
children: React.ReactNode;
|
|
74
|
-
/**
|
|
75
|
-
* Display the button in a loading state
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
loading?: boolean;
|
|
79
|
-
style?: React.CSSProperties;
|
|
80
|
-
} & ButtonOrLinkProps;
|
|
81
|
-
declare function Button(props: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
82
|
-
|
|
83
|
-
export { Button, type ButtonProps };
|