@obosbbl/grunnmuren-react 1.1.0 → 1.2.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.
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export interface RadioProps extends React.ComponentPropsWithoutRef<'input'> {
3
+ children: React.ReactNode;
4
+ }
5
+ export declare const Radio: (props: RadioProps) => JSX.Element;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare const RadioContext: import("react").Context<{
3
+ defaultValue?: string | undefined;
4
+ isControlled: boolean;
5
+ name?: string | undefined;
6
+ onChange?(event: React.ChangeEvent<HTMLInputElement>): void;
7
+ required?: boolean | undefined;
8
+ value?: string | undefined;
9
+ }>;
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ export interface RadioGroupProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'onChange'> {
3
+ /** The value of the radio button to be initially selected. For uncontrolled usage */
4
+ defaultValue?: string;
5
+ /** Help text for the radio group. */
6
+ description?: string;
7
+ /** The `name` attribute for the radio buttons. */
8
+ name: string;
9
+ /** The label for the radio group. */
10
+ label?: string;
11
+ /** Event handler called when the value changes. */
12
+ onChange?(value: string): void;
13
+ /** Whether a value selection is required. */
14
+ required?: boolean;
15
+ /** The value of the selected radio button. For controlled usage */
16
+ value?: string;
17
+ }
18
+ export declare const RadioGroup: (props: RadioGroupProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './Radio';
2
+ export * from './RadioGroup';
@@ -51,6 +51,19 @@ var __spreadValues2 = (a, b) => {
51
51
  return a;
52
52
  };
53
53
  var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
54
+ const ChevronDown = (props) => /* @__PURE__ */ jsx("svg", __spreadProps2(__spreadValues2({
55
+ width: "1.25em",
56
+ height: "1.25em",
57
+ fill: "none",
58
+ viewBox: "0 0 29 17",
59
+ role: "img",
60
+ "aria-hidden": props["aria-label"] == null
61
+ }, props), {
62
+ children: /* @__PURE__ */ jsx("path", {
63
+ fill: "currentColor",
64
+ 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"
65
+ })
66
+ }));
54
67
  const Close = (props) => /* @__PURE__ */ jsx("svg", __spreadProps2(__spreadValues2({
55
68
  width: "1.25em",
56
69
  height: "1.25em",
@@ -311,7 +324,7 @@ const Button = forwardRef((props, ref) => {
311
324
  const colorFromContext = useContext(ButtonColorContext);
312
325
  const color = colorFromProp != null ? colorFromProp : colorFromContext;
313
326
  const buttonVariation = buttonVariations[`${color}-${variant}`];
314
- const classes = classNames(className, buttonVariation, "button relative no-underline inline-block border-solid border-2 px-6 py-2 rounded-xl transition-all duration-200 font-medium w-fit disabled:pointer-events-none disabled:text-black disabled:bg-gray-light disabled:border-gray-light hover:rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-black ring-offset-2");
327
+ const classes = classNames(className, buttonVariation, "button");
315
328
  return /* @__PURE__ */ jsx(Fragment, {
316
329
  children: href ? /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({}, rest), {
317
330
  href,
@@ -466,7 +479,7 @@ const Checkbox = forwardRef((props, ref) => {
466
479
  className: classNames(className, "inline-flex cursor-pointer items-center"),
467
480
  children: [/* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({
468
481
  id,
469
- className: classNames("checkbox checked:bg-green checked:border-green bg-whit mr-3 grid h-[1.25em] w-[1.25em] flex-none cursor-pointer appearance-none place-content-center rounded border-2 border-solid text-white focus:outline-none focus:ring-2", {
482
+ className: classNames("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", {
470
483
  "border-gray-dark focus:ring-black": !error,
471
484
  "border-red focus:ring-red": !!error
472
485
  }),
@@ -961,6 +974,101 @@ const NavbarExpandedMobileContent = (props) => {
961
974
  children: props.children
962
975
  });
963
976
  };
977
+ const RadioContext = createContext({
978
+ defaultValue: void 0,
979
+ isControlled: false,
980
+ name: void 0,
981
+ onChange() {
982
+ },
983
+ required: false,
984
+ value: void 0
985
+ });
986
+ const Radio = (props) => {
987
+ const _a = props, {
988
+ children,
989
+ className
990
+ } = _a, rest = __objRest(_a, [
991
+ "children",
992
+ "className"
993
+ ]);
994
+ const {
995
+ defaultValue,
996
+ isControlled,
997
+ name,
998
+ onChange,
999
+ required,
1000
+ value
1001
+ } = useContext(RadioContext);
1002
+ return /* @__PURE__ */ jsxs("label", {
1003
+ className: classNames(className, "cursor-pointer"),
1004
+ children: [/* @__PURE__ */ jsx("input", __spreadValues({
1005
+ className: "radio",
1006
+ defaultChecked: !isControlled ? rest.value === defaultValue : void 0,
1007
+ checked: isControlled ? rest.value === value : void 0,
1008
+ name,
1009
+ onChange: isControlled ? onChange : void 0,
1010
+ required,
1011
+ type: "radio"
1012
+ }, rest)), children]
1013
+ });
1014
+ };
1015
+ const RadioGroup = (props) => {
1016
+ const isControlled = "value" in props;
1017
+ const _a = props, {
1018
+ className,
1019
+ defaultValue,
1020
+ description,
1021
+ children,
1022
+ label,
1023
+ name,
1024
+ onChange: onChangeProp,
1025
+ required,
1026
+ value
1027
+ } = _a, rest = __objRest(_a, [
1028
+ "className",
1029
+ "defaultValue",
1030
+ "description",
1031
+ "children",
1032
+ "label",
1033
+ "name",
1034
+ "onChange",
1035
+ "required",
1036
+ "value"
1037
+ ]);
1038
+ const onChange = useCallback((event) => {
1039
+ const nextValue = event.target.value;
1040
+ onChangeProp == null ? void 0 : onChangeProp(nextValue);
1041
+ }, [onChangeProp]);
1042
+ const group = useMemo(() => ({
1043
+ defaultValue,
1044
+ isControlled,
1045
+ name,
1046
+ onChange,
1047
+ required,
1048
+ value
1049
+ }), [defaultValue, isControlled, name, onChange, required, value]);
1050
+ const groupId = useId();
1051
+ const labelId = `${groupId}:label`;
1052
+ const helpId = `${groupId}:help`;
1053
+ return /* @__PURE__ */ jsx(RadioContext.Provider, {
1054
+ value: group,
1055
+ children: /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({
1056
+ "aria-describedby": description ? helpId : void 0,
1057
+ "aria-labelledby": label ? labelId : void 0,
1058
+ className: classNames(className, "flex flex-col gap-4"),
1059
+ role: "radiogroup"
1060
+ }, rest), {
1061
+ children: [label && /* @__PURE__ */ jsx(FormLabel, {
1062
+ id: labelId,
1063
+ isRequired: required,
1064
+ children: label
1065
+ }), children, /* @__PURE__ */ jsx(FormHelperText, {
1066
+ id: helpId,
1067
+ children: description
1068
+ })]
1069
+ }))
1070
+ });
1071
+ };
964
1072
  const Snackbar = (props) => {
965
1073
  const {
966
1074
  heading,
@@ -1140,4 +1248,23 @@ const TextField = forwardRef((props, ref) => {
1140
1248
  })]
1141
1249
  });
1142
1250
  });
1143
- export { Alert, Banner, BannerImage, Button, ButtonColorContext, Campaign, Card, CardContent, CardImage, CardLinkOverlay, CardList, Checkbox, Footer, Form, FormError, FormErrorMessage, FormHeading, FormHelperText, FormLabel, FormSuccess, Hero, HeroActions, HeroContent, HeroContext, HeroImage, Input, Link, Navbar, NavbarCollapsible, NavbarContent, NavbarExpandedMobileContent, NavbarItem, NavbarItems, Snackbar, SnackbarButton, SnackbarContent, StepList, StepListItem, TextArea, TextField, assignRef, useBlockBackgroundColor, useComposedRefs, useFallbackId, useFormControlValidity, useMedia, usePrefersReducedMotion, useScreenMaxWidthMd };
1251
+ const Select = forwardRef((props, ref) => {
1252
+ const _a = props, {
1253
+ children,
1254
+ className
1255
+ } = _a, rest = __objRest(_a, [
1256
+ "children",
1257
+ "className"
1258
+ ]);
1259
+ return /* @__PURE__ */ jsxs("div", {
1260
+ className: classNames("relative", className),
1261
+ children: [/* @__PURE__ */ jsx("select", __spreadProps(__spreadValues({}, rest), {
1262
+ 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",
1263
+ ref,
1264
+ children
1265
+ })), /* @__PURE__ */ jsx(ChevronDown, {
1266
+ className: "absolute top-4 right-4"
1267
+ })]
1268
+ });
1269
+ });
1270
+ export { Alert, Banner, BannerImage, Button, ButtonColorContext, Campaign, Card, CardContent, CardImage, CardLinkOverlay, CardList, Checkbox, 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, assignRef, useBlockBackgroundColor, useComposedRefs, useFallbackId, useFormControlValidity, useMedia, usePrefersReducedMotion, useScreenMaxWidthMd };
package/dist/index.d.ts CHANGED
@@ -10,8 +10,10 @@ export * from './Hero';
10
10
  export * from './Input';
11
11
  export * from './Link';
12
12
  export * from './Navbar';
13
+ export * from './Radio';
13
14
  export * from './Snackbar';
14
15
  export * from './StepList';
15
16
  export * from './TextArea';
16
17
  export * from './TextField';
17
18
  export * from './hooks';
19
+ export * from './Select';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "OBOS Grunnmuren design system React components",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,32 +17,32 @@
17
17
  ],
18
18
  "types": "./dist/index.d.ts",
19
19
  "devDependencies": {
20
- "@babel/core": "7.18.6",
21
- "@obosbbl/grunnmuren-tailwind": "^0.4.1",
22
- "@storybook/addon-controls": "6.5.9",
23
- "@storybook/addon-docs": "6.5.9",
20
+ "@babel/core": "7.18.10",
21
+ "@obosbbl/grunnmuren-tailwind": "0.5.0",
22
+ "@storybook/addon-controls": "6.5.10",
23
+ "@storybook/addon-docs": "6.5.10",
24
24
  "@storybook/addon-postcss": "2.0.0",
25
- "@storybook/builder-webpack5": "6.5.9",
26
- "@storybook/manager-webpack5": "6.5.9",
27
- "@storybook/react": "6.5.9",
28
- "@types/react": "18.0.14",
29
- "@types/react-dom": "18.0.5",
25
+ "@storybook/builder-webpack5": "6.5.10",
26
+ "@storybook/manager-webpack5": "6.5.10",
27
+ "@storybook/react": "6.5.10",
28
+ "@types/react": "18.0.17",
29
+ "@types/react-dom": "18.0.6",
30
30
  "@vitejs/plugin-react": "1.3.2",
31
- "postcss": "8.4.14",
31
+ "postcss": "8.4.16",
32
32
  "react": "18.2.0",
33
33
  "react-dom": "18.2.0",
34
34
  "require-from-string": "2.0.2",
35
- "tailwindcss": "3.1.4",
36
- "vite": "2.9.13",
37
- "webpack": "5.73.0"
35
+ "tailwindcss": "3.1.8",
36
+ "vite": "2.9.15",
37
+ "webpack": "5.74.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@obosbbl/grunnmuren-icons": "^0.3.0",
41
- "clsx": "1.2.0"
41
+ "clsx": "1.2.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": "^18",
45
- "@obosbbl/grunnmuren-tailwind": "^0.4.1"
45
+ "@obosbbl/grunnmuren-tailwind": "^0.5.0"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "@obosbbl/grunnmuren-tailwind": {