@obosbbl/grunnmuren-react 1.7.0 → 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.
@@ -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
- id?: string;
5
- className?: string;
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>>;
@@ -633,10 +633,10 @@ const Checkbox = forwardRef((props, ref) => {
633
633
  return /* @__PURE__ */ jsxs("div", {
634
634
  className: "grid gap-2",
635
635
  children: [/* @__PURE__ */ jsxs("label", {
636
- className: cx(className, "inline-flex cursor-pointer items-center"),
636
+ className: cx(className, "flex cursor-pointer gap-2.5"),
637
637
  children: [/* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({
638
638
  id,
639
- className: cx("checkbox checked:bg-green checked:border-green mr-3 grid h-[1.25em] w-[1.25em] flex-none cursor-pointer appearance-none place-content-center rounded border-2 border-solid bg-white text-white focus:outline-none focus:ring-2", {
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", {
640
640
  "border-gray-dark focus:ring-black": !error,
641
641
  "border-red focus:ring-red": !!error
642
642
  }),
@@ -760,7 +760,7 @@ const FormErrorMessage = (props) => {
760
760
  "className"
761
761
  ]);
762
762
  return /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({
763
- className: cx(className, "bg-red-light text-red flex items-center gap-2 rounded-lg py-1 px-4 text-sm"),
763
+ className: cx(className, "bg-red-light text-red flex items-center gap-2 rounded py-1 px-2 text-sm"),
764
764
  "aria-live": "polite"
765
765
  }, rest), {
766
766
  children: [/* @__PURE__ */ jsx(Warning, {
@@ -985,7 +985,7 @@ const Input = forwardRef((props, ref) => {
985
985
  const Component = as != null ? as : "input";
986
986
  const type = getType(Component, typeProp);
987
987
  return /* @__PURE__ */ jsxs("div", {
988
- className: cx(className, "relative flex items-center rounded-md border-[1px] border-b-[3px] focus-within:-ml-[2px] focus-within:-mt-[2px] focus-within:border-[3px] focus-within:shadow", {
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", {
989
989
  "focus-within:border-blue-dark border-black": !isInvalid,
990
990
  "border-red focus-within:border-red": isInvalid,
991
991
  "w-fit": size != null,
@@ -996,7 +996,7 @@ const Input = forwardRef((props, ref) => {
996
996
  children: [leftAddon, /* @__PURE__ */ jsx(Component, __spreadValues({
997
997
  "aria-invalid": isInvalid,
998
998
  ref,
999
- className: "focus:none placeholder-gray w-full rounded-md border-none px-4 py-3.5 focus:outline-none",
999
+ className: "focus:none placeholder-gray w-full rounded-lg border-none px-4 py-3.5 focus:outline-none",
1000
1000
  size,
1001
1001
  type
1002
1002
  }, rest)), rightAddon]
@@ -1333,7 +1333,7 @@ const Radio = forwardRef((props, ref) => {
1333
1333
  value
1334
1334
  } = useContext(RadioContext);
1335
1335
  return /* @__PURE__ */ jsxs("label", {
1336
- className: cx(className, "cursor-pointer"),
1336
+ className: cx(className, "flex cursor-pointer gap-2.5"),
1337
1337
  children: [/* @__PURE__ */ jsx("input", __spreadValues({
1338
1338
  className: "radio",
1339
1339
  defaultChecked: !isControlled ? rest.value === defaultValue : void 0,
@@ -1404,22 +1404,77 @@ const RadioGroup = forwardRef((props, ref) => {
1404
1404
  }))
1405
1405
  });
1406
1406
  });
1407
- const Select = forwardRef((props, ref) => {
1407
+ const SelectPlain = forwardRef((props, ref) => {
1408
1408
  const _a = props, {
1409
1409
  children,
1410
- className
1410
+ className,
1411
+ isInvalid,
1412
+ size
1411
1413
  } = _a, rest = __objRest(_a, [
1412
1414
  "children",
1413
- "className"
1415
+ "className",
1416
+ "isInvalid",
1417
+ "size"
1414
1418
  ]);
1419
+ const isSmall = size === "small";
1415
1420
  return /* @__PURE__ */ jsxs("div", {
1416
- className: cx("relative", className),
1417
- children: [/* @__PURE__ */ jsx("select", __spreadProps(__spreadValues({}, rest), {
1418
- className: "focus:border-blue border-gray-dark w-full appearance-none rounded-lg border-2 border-solid bg-white px-4 py-3 focus:outline-none",
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"),
1419
1426
  ref,
1420
1427
  children
1421
1428
  })), /* @__PURE__ */ jsx(ChevronDown, {
1422
- className: "absolute top-4 right-4"
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
1423
1478
  })]
1424
1479
  });
1425
1480
  });
@@ -1521,7 +1576,7 @@ const StepListBullet = (_a) => {
1521
1576
  ]);
1522
1577
  return /* @__PURE__ */ jsx("span", __spreadValues({
1523
1578
  "aria-hidden": true,
1524
- 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 ", {
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", {
1525
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",
1526
1581
  "after:top-10 after:-bottom-8 after:md:-bottom-12 after:md:top-20": align === "top"
1527
1582
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "OBOS Grunnmuren design system React components",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,14 +17,14 @@
17
17
  ],
18
18
  "types": "./dist/index.d.ts",
19
19
  "devDependencies": {
20
- "@babel/core": "7.20.2",
20
+ "@babel/core": "7.20.5",
21
21
  "@storybook/addon-controls": "6.5.14",
22
22
  "@storybook/addon-docs": "6.5.14",
23
23
  "@storybook/addon-postcss": "2.0.0",
24
24
  "@storybook/builder-webpack5": "6.5.14",
25
25
  "@storybook/manager-webpack5": "6.5.14",
26
26
  "@storybook/react": "6.5.14",
27
- "@types/react": "18.0.25",
27
+ "@types/react": "18.0.26",
28
28
  "@types/react-dom": "18.0.9",
29
29
  "@vitejs/plugin-react": "1.3.2",
30
30
  "postcss": "8.4.19",
@@ -36,7 +36,7 @@
36
36
  "type-fest": "3.3.0",
37
37
  "vite": "2.9.15",
38
38
  "webpack": "5.75.0",
39
- "@obosbbl/grunnmuren-tailwind": "0.8.3"
39
+ "@obosbbl/grunnmuren-tailwind": "0.8.4"
40
40
  },
41
41
  "dependencies": {
42
42
  "@seznam/compose-react-refs": "1.0.6",
@@ -46,7 +46,7 @@
46
46
  "@obosbbl/grunnmuren-icons": "^0.5.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@obosbbl/grunnmuren-tailwind": "^0.8.3",
49
+ "@obosbbl/grunnmuren-tailwind": "^0.8.4",
50
50
  "react": "^18"
51
51
  },
52
52
  "peerDependenciesMeta": {