@obosbbl/grunnmuren-react 1.6.2 → 1.8.0
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/Button/Button.d.ts +1 -1
- package/dist/Chip/Chip.d.ts +1 -1
- package/dist/Hero/Hero.d.ts +2 -2
- package/dist/Pagination/Pagination.d.ts +23 -0
- package/dist/Pagination/index.d.ts +1 -0
- package/dist/Select/Select.d.ts +17 -3
- package/dist/Select/SelectPlain.d.ts +15 -0
- package/dist/StepList/StepList.d.ts +14 -2
- package/dist/grunnmuren.es.js +275 -20
- package/dist/hooks/useBlockBackgroundColor.d.ts +1 -1
- package/dist/hooks/useFormControlValidity.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +14 -13
package/dist/Button/Button.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type ButtonColor = 'standard' | 'white' | 'light-green';
|
|
3
3
|
export interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
className?: string;
|
package/dist/Chip/Chip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export type ChipColor = 'blue-light' | 'green-light' | 'red-light' | 'orange-light';
|
|
3
3
|
export interface ChipProps {
|
|
4
4
|
icon?: React.ReactNode;
|
|
5
5
|
color?: ChipColor;
|
package/dist/Hero/Hero.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export declare const HeroContext: import("react").Context<{
|
|
|
4
4
|
contentPosition: HeroContentPosition;
|
|
5
5
|
hasImage: boolean;
|
|
6
6
|
}>;
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type HeroColor = 'green' | 'blue' | 'white';
|
|
8
|
+
export type HeroContentPosition = 'below-center' | 'below-left' | 'top-left' | 'bottom-left' | 'top-right' | 'bottom-right' | 'center' | 'vertical-split';
|
|
9
9
|
export interface HeroProps {
|
|
10
10
|
/** @default white */
|
|
11
11
|
bgColor?: HeroColor;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
3
|
+
interface BasePaginationProps extends Omit<React.ComponentPropsWithoutRef<'nav'>, 'onChange'> {
|
|
4
|
+
/** The current page number.
|
|
5
|
+
* @note Starts at 1
|
|
6
|
+
*/
|
|
7
|
+
page: number;
|
|
8
|
+
/** The total number of pages. */
|
|
9
|
+
count: number;
|
|
10
|
+
/** Given a page number, should return a valid href string. */
|
|
11
|
+
getItemHref: (page: number) => string;
|
|
12
|
+
/** Given a page number, should return a valid href string. */
|
|
13
|
+
getItemAriaLabel: (page: number) => string;
|
|
14
|
+
/** Aria label for the next page button link */
|
|
15
|
+
nextPageAriaLabel: string;
|
|
16
|
+
/** Aria label for the previous page button link */
|
|
17
|
+
prevPageAriaLabel: string;
|
|
18
|
+
/** Handler that is called with the page number to navigate to. `event.preventDefault` is called for you. Fallbacks to default browser behavior if undefined. */
|
|
19
|
+
onChange?: (page: number) => void;
|
|
20
|
+
}
|
|
21
|
+
type PaginationProps = RequireAtLeastOne<BasePaginationProps, 'aria-label' | 'aria-labelledby'>;
|
|
22
|
+
export declare const Pagination: (props: PaginationProps) => JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Pagination';
|
package/dist/Select/Select.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export interface SelectProps extends React.ComponentPropsWithoutRef<'select'> {
|
|
2
|
+
export interface SelectProps extends Omit<React.ComponentPropsWithoutRef<'select'>, 'size'> {
|
|
3
|
+
/**
|
|
4
|
+
* Collection of <option />-elements
|
|
5
|
+
*/
|
|
3
6
|
children: React.ReactNode;
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
/** Help text for the form control */
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
/** Disables the built in HTML5 validation. If using custom validation for an entire form, consider setting `noValidate` on the form element instead. @default false */
|
|
10
|
+
disableValidation?: boolean;
|
|
11
|
+
/** Error message for the form control */
|
|
12
|
+
error?: string;
|
|
13
|
+
/** Label for the form control */
|
|
14
|
+
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Changes font-size, padding and gaps
|
|
17
|
+
* @default medium
|
|
18
|
+
*/
|
|
19
|
+
size?: 'medium' | 'small';
|
|
6
20
|
}
|
|
7
21
|
export declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface SelectPlainProps extends Omit<React.ComponentPropsWithoutRef<'select'>, 'size'> {
|
|
3
|
+
/**
|
|
4
|
+
* Collection of <option />-elements
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Render select as invalid. Sets `aria-invalid` to true */
|
|
8
|
+
isInvalid?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Changes font-size, padding and gaps
|
|
11
|
+
* @default medium
|
|
12
|
+
*/
|
|
13
|
+
size?: 'medium' | 'small';
|
|
14
|
+
}
|
|
15
|
+
export declare const SelectPlain: import("react").ForwardRefExoticComponent<SelectPlainProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
type Alignment = 'center' | 'top';
|
|
3
|
+
export interface StepListProps extends React.ComponentPropsWithoutRef<'ol'> {
|
|
4
|
+
/**
|
|
5
|
+
* Determines the vertical alignment of the bullets
|
|
6
|
+
* @default 'center'
|
|
7
|
+
*/
|
|
8
|
+
align?: Alignment;
|
|
9
|
+
/**
|
|
10
|
+
* <StepList> items
|
|
11
|
+
*/
|
|
12
|
+
children: React.ReactNode;
|
|
3
13
|
}
|
|
4
14
|
declare const StepList: {
|
|
5
15
|
(props: StepListProps): JSX.Element;
|
|
6
16
|
Item: (props: StepListItemProps) => JSX.Element;
|
|
7
17
|
};
|
|
8
|
-
interface StepListItemProps extends React.ComponentPropsWithoutRef<'li'> {
|
|
18
|
+
export interface StepListItemProps extends React.ComponentPropsWithoutRef<'li'> {
|
|
9
19
|
/** Content for the StepListItem's bullet */
|
|
10
20
|
bullet: React.ReactNode;
|
|
21
|
+
/** @private this is set by the parent StepList component */
|
|
22
|
+
align?: Alignment;
|
|
11
23
|
}
|
|
12
24
|
export declare const StepListItem: (props: StepListItemProps) => JSX.Element;
|
|
13
25
|
export { StepList };
|
package/dist/grunnmuren.es.js
CHANGED
|
@@ -68,6 +68,32 @@ const ChevronDown = (props) => /* @__PURE__ */ jsx("svg", __spreadProps2(__sprea
|
|
|
68
68
|
d: "M0 4.31662L4.31662 0L14.3752 10.0484L24.4337 0L28.7503 4.31662L17.2563 15.8106C16.4929 16.5722 15.4586 16.9999 14.3803 16.9999C13.3019 16.9999 12.2676 16.5722 11.5042 15.8106L0 4.31662Z"
|
|
69
69
|
})
|
|
70
70
|
}));
|
|
71
|
+
const ChevronLeft = (props) => /* @__PURE__ */ jsx("svg", __spreadProps2(__spreadValues2({
|
|
72
|
+
width: "1.25em",
|
|
73
|
+
height: "1.25em",
|
|
74
|
+
fill: "none",
|
|
75
|
+
viewBox: "0 0 17 29",
|
|
76
|
+
role: "img",
|
|
77
|
+
"aria-hidden": props["aria-label"] == null
|
|
78
|
+
}, props), {
|
|
79
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
80
|
+
fill: "currentColor",
|
|
81
|
+
d: "M12.6771 0L17 4.31278L6.95043 14.3624L17 24.4119L12.6771 28.7247L1.19328 17.2409C0.814993 16.8631 0.514893 16.4143 0.310141 15.9204C0.105389 15.4265 0 14.897 0 14.3624C0 13.8277 0.105389 13.2982 0.310141 12.8043C0.514893 12.3104 0.814993 11.8616 1.19328 11.4838L12.6771 0Z"
|
|
82
|
+
})
|
|
83
|
+
}));
|
|
84
|
+
const ChevronRight = (props) => /* @__PURE__ */ jsx("svg", __spreadProps2(__spreadValues2({
|
|
85
|
+
width: "1.25em",
|
|
86
|
+
height: "1.25em",
|
|
87
|
+
fill: "none",
|
|
88
|
+
viewBox: "0 0 17 29",
|
|
89
|
+
role: "img",
|
|
90
|
+
"aria-hidden": props["aria-label"] == null
|
|
91
|
+
}, props), {
|
|
92
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
93
|
+
fill: "currentColor",
|
|
94
|
+
d: "M4.32295 28.7247L0 24.4119L10.0496 14.3624L0 4.31278L4.32295 0L15.8067 11.4838C16.185 11.8616 16.4851 12.3104 16.6899 12.8043C16.8946 13.2982 17 13.8277 17 14.3624C17 14.897 16.8946 15.4265 16.6899 15.9204C16.4851 16.4143 16.185 16.8631 15.8067 17.2409L4.32295 28.7247Z"
|
|
95
|
+
})
|
|
96
|
+
}));
|
|
71
97
|
const Close = (props) => /* @__PURE__ */ jsx("svg", __spreadProps2(__spreadValues2({
|
|
72
98
|
width: "1.25em",
|
|
73
99
|
height: "1.25em",
|
|
@@ -607,10 +633,10 @@ const Checkbox = forwardRef((props, ref) => {
|
|
|
607
633
|
return /* @__PURE__ */ jsxs("div", {
|
|
608
634
|
className: "grid gap-2",
|
|
609
635
|
children: [/* @__PURE__ */ jsxs("label", {
|
|
610
|
-
className: cx(className, "
|
|
636
|
+
className: cx(className, "flex cursor-pointer gap-2.5"),
|
|
611
637
|
children: [/* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({
|
|
612
638
|
id,
|
|
613
|
-
className: cx("checkbox checked:bg-green checked:border-green
|
|
639
|
+
className: cx("checkbox checked:bg-green checked:border-green grid h-[1.25em] w-[1.25em] flex-none translate-y-[0.1em] cursor-pointer appearance-none place-content-center rounded border-2 border-solid bg-white text-white focus:outline-none focus:ring-2", {
|
|
614
640
|
"border-gray-dark focus:ring-black": !error,
|
|
615
641
|
"border-red focus:ring-red": !!error
|
|
616
642
|
}),
|
|
@@ -734,7 +760,7 @@ const FormErrorMessage = (props) => {
|
|
|
734
760
|
"className"
|
|
735
761
|
]);
|
|
736
762
|
return /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({
|
|
737
|
-
className: cx(className, "bg-red-light text-red flex items-center gap-2 rounded
|
|
763
|
+
className: cx(className, "bg-red-light text-red flex items-center gap-2 rounded py-1 px-2 text-sm"),
|
|
738
764
|
"aria-live": "polite"
|
|
739
765
|
}, rest), {
|
|
740
766
|
children: [/* @__PURE__ */ jsx(Warning, {
|
|
@@ -959,7 +985,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
959
985
|
const Component = as != null ? as : "input";
|
|
960
986
|
const type = getType(Component, typeProp);
|
|
961
987
|
return /* @__PURE__ */ jsxs("div", {
|
|
962
|
-
className: cx(className, "relative flex items-center rounded-
|
|
988
|
+
className: cx(className, "relative flex items-center rounded-lg border border-b-[3px] focus-within:-ml-[2px] focus-within:-mt-[2px] focus-within:border-[3px] focus-within:shadow", {
|
|
963
989
|
"focus-within:border-blue-dark border-black": !isInvalid,
|
|
964
990
|
"border-red focus-within:border-red": isInvalid,
|
|
965
991
|
"w-fit": size != null,
|
|
@@ -970,7 +996,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
970
996
|
children: [leftAddon, /* @__PURE__ */ jsx(Component, __spreadValues({
|
|
971
997
|
"aria-invalid": isInvalid,
|
|
972
998
|
ref,
|
|
973
|
-
className: "focus:none placeholder-gray w-full rounded-
|
|
999
|
+
className: "focus:none placeholder-gray w-full rounded-lg border-none px-4 py-3.5 focus:outline-none",
|
|
974
1000
|
size,
|
|
975
1001
|
type
|
|
976
1002
|
}, rest)), rightAddon]
|
|
@@ -1138,6 +1164,150 @@ const NavbarExpandedMobileContent = (props) => {
|
|
|
1138
1164
|
children: props.children
|
|
1139
1165
|
});
|
|
1140
1166
|
};
|
|
1167
|
+
const SIBLING_COUNT = 2;
|
|
1168
|
+
const PaginationContext = createContext({
|
|
1169
|
+
currentPage: 0,
|
|
1170
|
+
pageCount: 0
|
|
1171
|
+
});
|
|
1172
|
+
const Pagination = (props) => {
|
|
1173
|
+
const _a = props, {
|
|
1174
|
+
className,
|
|
1175
|
+
page: currentPage,
|
|
1176
|
+
count: pageCount,
|
|
1177
|
+
onChange,
|
|
1178
|
+
getItemHref,
|
|
1179
|
+
getItemAriaLabel,
|
|
1180
|
+
nextPageAriaLabel,
|
|
1181
|
+
prevPageAriaLabel
|
|
1182
|
+
} = _a, rest = __objRest(_a, [
|
|
1183
|
+
"className",
|
|
1184
|
+
"page",
|
|
1185
|
+
"count",
|
|
1186
|
+
"onChange",
|
|
1187
|
+
"getItemHref",
|
|
1188
|
+
"getItemAriaLabel",
|
|
1189
|
+
"nextPageAriaLabel",
|
|
1190
|
+
"prevPageAriaLabel"
|
|
1191
|
+
]);
|
|
1192
|
+
const context = useMemo(() => ({
|
|
1193
|
+
currentPage: Math.max(1, Math.min(currentPage, pageCount)),
|
|
1194
|
+
pageCount: Math.max(1, pageCount)
|
|
1195
|
+
}), [currentPage, pageCount]);
|
|
1196
|
+
const handleClick = (page) => (event) => {
|
|
1197
|
+
if (onChange) {
|
|
1198
|
+
event.preventDefault();
|
|
1199
|
+
onChange(page);
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
return /* @__PURE__ */ jsx(PaginationContext.Provider, {
|
|
1203
|
+
value: context,
|
|
1204
|
+
children: /* @__PURE__ */ jsxs("nav", __spreadProps(__spreadValues({
|
|
1205
|
+
className: cx("flex justify-center gap-2 sm:gap-4", className)
|
|
1206
|
+
}, rest), {
|
|
1207
|
+
children: [/* @__PURE__ */ jsx(PrevPage, {
|
|
1208
|
+
"aria-label": prevPageAriaLabel,
|
|
1209
|
+
href: getItemHref(currentPage - 1),
|
|
1210
|
+
onClick: handleClick(currentPage - 1)
|
|
1211
|
+
}), /* @__PURE__ */ jsx(PageItem, {
|
|
1212
|
+
page: 1,
|
|
1213
|
+
href: getItemHref(1),
|
|
1214
|
+
onClick: handleClick(1),
|
|
1215
|
+
"aria-label": getItemAriaLabel(1),
|
|
1216
|
+
selected: currentPage === 1
|
|
1217
|
+
}), pageCount > 2 + SIBLING_COUNT * 2 && currentPage > SIBLING_COUNT + 2 && /* @__PURE__ */ jsx(PaginationEllipsis, {}), /* @__PURE__ */ jsx(Pages, {
|
|
1218
|
+
children: (page) => /* @__PURE__ */ jsx(PageItem, {
|
|
1219
|
+
href: getItemHref(page),
|
|
1220
|
+
onClick: handleClick(page),
|
|
1221
|
+
"aria-label": getItemAriaLabel(page),
|
|
1222
|
+
page,
|
|
1223
|
+
selected: page === currentPage
|
|
1224
|
+
}, page)
|
|
1225
|
+
}), /* @__PURE__ */ jsx(NextPage, {
|
|
1226
|
+
"aria-label": nextPageAriaLabel,
|
|
1227
|
+
href: getItemHref(currentPage + 1),
|
|
1228
|
+
onClick: handleClick(currentPage + 1)
|
|
1229
|
+
})]
|
|
1230
|
+
}))
|
|
1231
|
+
});
|
|
1232
|
+
};
|
|
1233
|
+
const NextPage = forwardRef((props, ref) => {
|
|
1234
|
+
const {
|
|
1235
|
+
currentPage,
|
|
1236
|
+
pageCount
|
|
1237
|
+
} = useContext(PaginationContext);
|
|
1238
|
+
const hide = currentPage >= pageCount;
|
|
1239
|
+
return /* @__PURE__ */ jsx(PageLink, __spreadProps(__spreadValues({
|
|
1240
|
+
"aria-hidden": hide,
|
|
1241
|
+
className: hide ? "invisible" : void 0,
|
|
1242
|
+
ref,
|
|
1243
|
+
rel: "next"
|
|
1244
|
+
}, props), {
|
|
1245
|
+
children: /* @__PURE__ */ jsx(ChevronRight, {})
|
|
1246
|
+
}));
|
|
1247
|
+
});
|
|
1248
|
+
const PrevPage = forwardRef((props, ref) => {
|
|
1249
|
+
const {
|
|
1250
|
+
currentPage
|
|
1251
|
+
} = useContext(PaginationContext);
|
|
1252
|
+
const hide = currentPage <= 1;
|
|
1253
|
+
return /* @__PURE__ */ jsx(PageLink, __spreadProps(__spreadValues({
|
|
1254
|
+
"aria-hidden": hide,
|
|
1255
|
+
className: hide ? "invisible" : void 0,
|
|
1256
|
+
ref,
|
|
1257
|
+
rel: "prev"
|
|
1258
|
+
}, props), {
|
|
1259
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, {})
|
|
1260
|
+
}));
|
|
1261
|
+
});
|
|
1262
|
+
const PageLink = forwardRef((props, ref) => {
|
|
1263
|
+
const _a = props, {
|
|
1264
|
+
className
|
|
1265
|
+
} = _a, rest = __objRest(_a, [
|
|
1266
|
+
"className"
|
|
1267
|
+
]);
|
|
1268
|
+
return /* @__PURE__ */ jsx("a", __spreadValues({
|
|
1269
|
+
className: cx(className, "aria-[current]:border-green hover:bg-gray-concrete flex h-9 w-9 items-center justify-center rounded-lg border-2 border-transparent no-underline sm:h-10 sm:w-10"),
|
|
1270
|
+
ref
|
|
1271
|
+
}, rest));
|
|
1272
|
+
});
|
|
1273
|
+
const PaginationEllipsis = () => {
|
|
1274
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1275
|
+
className: "flex h-9 w-9 cursor-default items-center justify-center border-2 border-transparent sm:h-10 sm:w-10",
|
|
1276
|
+
children: "..."
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
const Pages = ({
|
|
1280
|
+
children
|
|
1281
|
+
}) => {
|
|
1282
|
+
const {
|
|
1283
|
+
currentPage,
|
|
1284
|
+
pageCount
|
|
1285
|
+
} = useContext(PaginationContext);
|
|
1286
|
+
const end = Math.min(Math.max(2 + SIBLING_COUNT * 2, currentPage + SIBLING_COUNT), pageCount);
|
|
1287
|
+
let start = Math.max(Math.min(currentPage - SIBLING_COUNT, end - SIBLING_COUNT * 2), 1);
|
|
1288
|
+
if (start - SIBLING_COUNT === 0) {
|
|
1289
|
+
start = start - 1;
|
|
1290
|
+
}
|
|
1291
|
+
const pages = Array.from({
|
|
1292
|
+
length: end - start
|
|
1293
|
+
}, (_, i) => start + i + 1);
|
|
1294
|
+
return pages.map((page) => children(page));
|
|
1295
|
+
};
|
|
1296
|
+
const PageItem = forwardRef((props, ref) => {
|
|
1297
|
+
const _a = props, {
|
|
1298
|
+
page,
|
|
1299
|
+
selected
|
|
1300
|
+
} = _a, rest = __objRest(_a, [
|
|
1301
|
+
"page",
|
|
1302
|
+
"selected"
|
|
1303
|
+
]);
|
|
1304
|
+
return /* @__PURE__ */ jsx(PageLink, __spreadProps(__spreadValues({
|
|
1305
|
+
"aria-current": selected ? "page" : void 0,
|
|
1306
|
+
ref
|
|
1307
|
+
}, rest), {
|
|
1308
|
+
children: page
|
|
1309
|
+
}));
|
|
1310
|
+
});
|
|
1141
1311
|
const RadioContext = createContext({
|
|
1142
1312
|
defaultValue: void 0,
|
|
1143
1313
|
isControlled: false,
|
|
@@ -1163,7 +1333,7 @@ const Radio = forwardRef((props, ref) => {
|
|
|
1163
1333
|
value
|
|
1164
1334
|
} = useContext(RadioContext);
|
|
1165
1335
|
return /* @__PURE__ */ jsxs("label", {
|
|
1166
|
-
className: cx(className, "cursor-pointer"),
|
|
1336
|
+
className: cx(className, "flex cursor-pointer gap-2.5"),
|
|
1167
1337
|
children: [/* @__PURE__ */ jsx("input", __spreadValues({
|
|
1168
1338
|
className: "radio",
|
|
1169
1339
|
defaultChecked: !isControlled ? rest.value === defaultValue : void 0,
|
|
@@ -1234,22 +1404,77 @@ const RadioGroup = forwardRef((props, ref) => {
|
|
|
1234
1404
|
}))
|
|
1235
1405
|
});
|
|
1236
1406
|
});
|
|
1237
|
-
const
|
|
1407
|
+
const SelectPlain = forwardRef((props, ref) => {
|
|
1238
1408
|
const _a = props, {
|
|
1239
1409
|
children,
|
|
1240
|
-
className
|
|
1410
|
+
className,
|
|
1411
|
+
isInvalid,
|
|
1412
|
+
size
|
|
1241
1413
|
} = _a, rest = __objRest(_a, [
|
|
1242
1414
|
"children",
|
|
1243
|
-
"className"
|
|
1415
|
+
"className",
|
|
1416
|
+
"isInvalid",
|
|
1417
|
+
"size"
|
|
1244
1418
|
]);
|
|
1419
|
+
const isSmall = size === "small";
|
|
1245
1420
|
return /* @__PURE__ */ jsxs("div", {
|
|
1246
|
-
className: cx("relative",
|
|
1247
|
-
children: [/* @__PURE__ */ jsx("select", __spreadProps(__spreadValues({
|
|
1248
|
-
|
|
1421
|
+
className: cx(className, "relative", isSmall && "text-sm"),
|
|
1422
|
+
children: [/* @__PURE__ */ jsx("select", __spreadProps(__spreadValues({
|
|
1423
|
+
"aria-invalid": isInvalid
|
|
1424
|
+
}, rest), {
|
|
1425
|
+
className: cx("w-full cursor-pointer appearance-none border border-b-[3px] bg-white focus:-mt-0.5 focus:-ml-0.5 focus:border-[3px] focus:shadow focus:outline-none", isSmall ? "rounded px-3.5 py-2" : "rounded-lg px-4 py-3.5", isInvalid ? "border-red focus:border-red" : "focus:border-blue-dark border-black"),
|
|
1249
1426
|
ref,
|
|
1250
1427
|
children
|
|
1251
1428
|
})), /* @__PURE__ */ jsx(ChevronDown, {
|
|
1252
|
-
className: "absolute top-
|
|
1429
|
+
className: cx("pointer-events-none absolute top-0 bottom-0 my-auto", isSmall ? "right-3.5" : "right-4")
|
|
1430
|
+
})]
|
|
1431
|
+
});
|
|
1432
|
+
});
|
|
1433
|
+
const Select = forwardRef((props, ref) => {
|
|
1434
|
+
const _a = props, {
|
|
1435
|
+
description,
|
|
1436
|
+
error,
|
|
1437
|
+
id: idProp,
|
|
1438
|
+
label,
|
|
1439
|
+
disableValidation = false
|
|
1440
|
+
} = _a, rest = __objRest(_a, [
|
|
1441
|
+
"description",
|
|
1442
|
+
"error",
|
|
1443
|
+
"id",
|
|
1444
|
+
"label",
|
|
1445
|
+
"disableValidation"
|
|
1446
|
+
]);
|
|
1447
|
+
const ownRef = useRef(null);
|
|
1448
|
+
const {
|
|
1449
|
+
validity,
|
|
1450
|
+
validationMessage
|
|
1451
|
+
} = useFormControlValidity(ownRef, !disableValidation);
|
|
1452
|
+
const id = useFallbackId(idProp);
|
|
1453
|
+
const helpTextId = id + "help";
|
|
1454
|
+
const errorMsgId = id + "err";
|
|
1455
|
+
const errorMsg = error || validationMessage;
|
|
1456
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1457
|
+
className: "grid gap-2",
|
|
1458
|
+
children: [/* @__PURE__ */ jsx(FormLabel, {
|
|
1459
|
+
htmlFor: id,
|
|
1460
|
+
isRequired: props.required,
|
|
1461
|
+
isInvalid: !!error || validity === "invalid",
|
|
1462
|
+
children: label
|
|
1463
|
+
}), description && /* @__PURE__ */ jsx(FormHelperText, {
|
|
1464
|
+
id: helpTextId,
|
|
1465
|
+
children: description
|
|
1466
|
+
}), /* @__PURE__ */ jsx(SelectPlain, __spreadProps(__spreadValues({
|
|
1467
|
+
id,
|
|
1468
|
+
ref: composeRefs(ownRef, ref)
|
|
1469
|
+
}, rest), {
|
|
1470
|
+
isInvalid: !!error || validity === "invalid",
|
|
1471
|
+
"aria-describedby": cx({
|
|
1472
|
+
[errorMsgId]: errorMsg,
|
|
1473
|
+
[helpTextId]: description
|
|
1474
|
+
}) || void 0
|
|
1475
|
+
})), errorMsg && /* @__PURE__ */ jsx(FormErrorMessage, {
|
|
1476
|
+
id: errorMsgId,
|
|
1477
|
+
children: errorMsg
|
|
1253
1478
|
})]
|
|
1254
1479
|
});
|
|
1255
1480
|
});
|
|
@@ -1301,30 +1526,60 @@ const SnackbarContent = (props) => {
|
|
|
1301
1526
|
}));
|
|
1302
1527
|
};
|
|
1303
1528
|
const StepList = (props) => {
|
|
1304
|
-
|
|
1529
|
+
const _a = props, {
|
|
1530
|
+
align = "center",
|
|
1531
|
+
children,
|
|
1532
|
+
className
|
|
1533
|
+
} = _a, rest = __objRest(_a, [
|
|
1534
|
+
"align",
|
|
1535
|
+
"children",
|
|
1536
|
+
"className"
|
|
1537
|
+
]);
|
|
1538
|
+
return /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({
|
|
1539
|
+
className: cx(className, "flex flex-col gap-8 md:gap-12")
|
|
1540
|
+
}, rest), {
|
|
1541
|
+
children: Children.map(children, (child) => {
|
|
1542
|
+
return cloneElement(child, {
|
|
1543
|
+
align
|
|
1544
|
+
});
|
|
1545
|
+
})
|
|
1546
|
+
}));
|
|
1305
1547
|
};
|
|
1306
1548
|
const StepListItem = (props) => {
|
|
1307
1549
|
const _a = props, {
|
|
1308
1550
|
className,
|
|
1309
1551
|
children,
|
|
1310
|
-
bullet
|
|
1552
|
+
bullet,
|
|
1553
|
+
align = "center"
|
|
1311
1554
|
} = _a, rest = __objRest(_a, [
|
|
1312
1555
|
"className",
|
|
1313
1556
|
"children",
|
|
1314
|
-
"bullet"
|
|
1557
|
+
"bullet",
|
|
1558
|
+
"align"
|
|
1315
1559
|
]);
|
|
1316
1560
|
return /* @__PURE__ */ jsxs("li", __spreadProps(__spreadValues({
|
|
1317
|
-
className: cx(className, "group relative flex
|
|
1561
|
+
className: cx(className, "group relative flex gap-4 text-sm md:gap-8 md:text-base", {
|
|
1562
|
+
"items-center": align === "center"
|
|
1563
|
+
})
|
|
1318
1564
|
}, rest), {
|
|
1319
1565
|
children: [/* @__PURE__ */ jsx(StepListBullet, {
|
|
1566
|
+
align,
|
|
1320
1567
|
children: bullet
|
|
1321
1568
|
}), children]
|
|
1322
1569
|
}));
|
|
1323
1570
|
};
|
|
1324
|
-
const StepListBullet = (
|
|
1571
|
+
const StepListBullet = (_a) => {
|
|
1572
|
+
var _b = _a, {
|
|
1573
|
+
align
|
|
1574
|
+
} = _b, props = __objRest(_b, [
|
|
1575
|
+
"align"
|
|
1576
|
+
]);
|
|
1325
1577
|
return /* @__PURE__ */ jsx("span", __spreadValues({
|
|
1326
1578
|
"aria-hidden": true,
|
|
1327
|
-
className: "text-green after:bg-gray-light grid h-10 w-10 flex-none place-content-center justify-items-center rounded-full border-2 text-sm font-bold after:absolute after:
|
|
1579
|
+
className: cx("text-green after:bg-gray-light before:bg-gray-light grid h-10 w-10 flex-none place-content-center justify-items-center rounded-full border-2 text-sm font-bold after:absolute after:bottom-0 after:w-0.5 after:translate-x-1/2 group-last:after:hidden md:h-20 md:w-20 md:text-xl", {
|
|
1580
|
+
"before:absolute before:top-0 before:bottom-1/2 before:w-0.5 before:-translate-y-5 before:translate-x-1/2 after:top-1/2 after:translate-y-5 group-first:before:hidden before:md:-translate-y-10 after:md:translate-y-10": align === "center",
|
|
1581
|
+
"after:top-10 after:-bottom-8 after:md:-bottom-12 after:md:top-20": align === "top"
|
|
1582
|
+
})
|
|
1328
1583
|
}, props));
|
|
1329
1584
|
};
|
|
1330
1585
|
StepList.Item = StepListItem;
|
|
@@ -1428,4 +1683,4 @@ const TextField = forwardRef((props, ref) => {
|
|
|
1428
1683
|
})]
|
|
1429
1684
|
});
|
|
1430
1685
|
});
|
|
1431
|
-
export { Accordion, AccordionContent, AccordionHeader, AccordionItem, Alert, Banner, BannerImage, Button, ButtonColorContext, Campaign, Card, CardContent, CardImage, CardLinkOverlay, CardList, Checkbox, Chip, Footer, Form, FormError, FormErrorMessage, FormHeading, FormHelperText, FormLabel, FormSuccess, Hero, HeroActions, HeroContent, HeroContext, HeroImage, Input, Link, Navbar, NavbarCollapsible, NavbarContent, NavbarExpandedMobileContent, NavbarItem, NavbarItems, Radio, RadioGroup, Select, Snackbar, SnackbarButton, SnackbarContent, StepList, StepListItem, TextArea, TextField, useBlockBackgroundColor, useFallbackId, useFormControlValidity, usePrefersReducedMotion, useScreenMaxWidthMd };
|
|
1686
|
+
export { Accordion, AccordionContent, AccordionHeader, AccordionItem, Alert, Banner, BannerImage, Button, ButtonColorContext, Campaign, Card, CardContent, CardImage, CardLinkOverlay, CardList, Checkbox, Chip, Footer, Form, FormError, FormErrorMessage, FormHeading, FormHelperText, FormLabel, FormSuccess, Hero, HeroActions, HeroContent, HeroContext, HeroImage, Input, Link, Navbar, NavbarCollapsible, NavbarContent, NavbarExpandedMobileContent, NavbarItem, NavbarItems, Pagination, Radio, RadioGroup, Select, Snackbar, SnackbarButton, SnackbarContent, StepList, StepListItem, TextArea, TextField, useBlockBackgroundColor, useFallbackId, useFormControlValidity, usePrefersReducedMotion, useScreenMaxWidthMd };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type BlockBackgroundColor = 'yellow' | 'gray' | 'blue' | 'green';
|
|
2
2
|
export declare function useBlockBackgroundColor(blockBgColor: BlockBackgroundColor | undefined): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
|
|
2
|
+
type Validity = 'indeterminate' | 'invalid' | 'valid';
|
|
3
3
|
/**
|
|
4
4
|
* Browser validation as it should be. "Invalid" only triggers after the user has blurred an input, or attempted
|
|
5
5
|
* to submit the form.
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obosbbl/grunnmuren-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "OBOS Grunnmuren design system React components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,25 +17,26 @@
|
|
|
17
17
|
],
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@babel/core": "7.
|
|
21
|
-
"@storybook/addon-controls": "6.5.
|
|
22
|
-
"@storybook/addon-docs": "6.5.
|
|
20
|
+
"@babel/core": "7.20.5",
|
|
21
|
+
"@storybook/addon-controls": "6.5.14",
|
|
22
|
+
"@storybook/addon-docs": "6.5.14",
|
|
23
23
|
"@storybook/addon-postcss": "2.0.0",
|
|
24
|
-
"@storybook/builder-webpack5": "6.5.
|
|
25
|
-
"@storybook/manager-webpack5": "6.5.
|
|
26
|
-
"@storybook/react": "6.5.
|
|
27
|
-
"@types/react": "18.0.
|
|
28
|
-
"@types/react-dom": "18.0.
|
|
24
|
+
"@storybook/builder-webpack5": "6.5.14",
|
|
25
|
+
"@storybook/manager-webpack5": "6.5.14",
|
|
26
|
+
"@storybook/react": "6.5.14",
|
|
27
|
+
"@types/react": "18.0.26",
|
|
28
|
+
"@types/react-dom": "18.0.9",
|
|
29
29
|
"@vitejs/plugin-react": "1.3.2",
|
|
30
|
-
"postcss": "8.4.
|
|
30
|
+
"postcss": "8.4.19",
|
|
31
31
|
"react": "18.2.0",
|
|
32
32
|
"react-dom": "18.2.0",
|
|
33
33
|
"require-from-string": "2.0.2",
|
|
34
34
|
"rimraf": "3.0.2",
|
|
35
35
|
"tailwindcss": "3.2.4",
|
|
36
|
+
"type-fest": "3.3.0",
|
|
36
37
|
"vite": "2.9.15",
|
|
37
|
-
"webpack": "5.
|
|
38
|
-
"@obosbbl/grunnmuren-tailwind": "0.8.
|
|
38
|
+
"webpack": "5.75.0",
|
|
39
|
+
"@obosbbl/grunnmuren-tailwind": "0.8.4"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@seznam/compose-react-refs": "1.0.6",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"@obosbbl/grunnmuren-icons": "^0.5.1"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"@obosbbl/grunnmuren-tailwind": "^0.8.
|
|
49
|
+
"@obosbbl/grunnmuren-tailwind": "^0.8.4",
|
|
49
50
|
"react": "^18"
|
|
50
51
|
},
|
|
51
52
|
"peerDependenciesMeta": {
|