@obosbbl/grunnmuren-react 1.2.1 → 1.3.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 +4 -2
- package/dist/Checkbox/Checkbox.d.ts +1 -1
- package/dist/Chip/Chip.d.ts +10 -0
- package/dist/Chip/index.d.ts +1 -0
- package/dist/grunnmuren.es.js +99 -6
- package/dist/index.d.ts +1 -0
- package/package.json +4 -4
package/dist/Button/Button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare type ButtonColor = 'standard' | 'white' | 'light-green';
|
|
3
3
|
export interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
|
4
4
|
children: React.ReactNode;
|
|
@@ -6,9 +6,11 @@ export interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
|
|
6
6
|
color?: 'standard' | 'white' | 'light-green';
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
href?: string;
|
|
9
|
+
/** Renders the button in a loading state */
|
|
10
|
+
loading?: boolean;
|
|
9
11
|
/** @default button */
|
|
10
12
|
type?: 'button' | 'submit' | 'reset';
|
|
11
13
|
/** @default primary */
|
|
12
14
|
variant?: 'primary' | 'secondary';
|
|
13
15
|
}
|
|
14
|
-
export declare const Button:
|
|
16
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
@@ -8,4 +8,4 @@ export interface CheckboxProps extends React.ComponentPropsWithRef<'input'> {
|
|
|
8
8
|
/** Error message for the form control */
|
|
9
9
|
error?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const Checkbox: import("react").ForwardRefExoticComponent<Pick<CheckboxProps, "className" | "children" | "form" | "slot" | "style" | "title" | "pattern" | "list" | "role" | "error" | "key" | "alt" | "crossOrigin" | "height" | "src" | "width" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "
|
|
11
|
+
export declare const Checkbox: import("react").ForwardRefExoticComponent<Pick<CheckboxProps, "className" | "children" | "form" | "slot" | "style" | "title" | "pattern" | "list" | "role" | "color" | "error" | "key" | "alt" | "crossOrigin" | "height" | "src" | "width" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "step" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "autoComplete" | "accept" | "capture" | "checked" | "multiple" | "maxLength" | "minLength" | "enterKeyHint" | "max" | "min" | "readOnly" | "required" | "size"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type ChipColor = 'blue-light' | 'green-light' | 'red-light' | 'orange-light';
|
|
3
|
+
export interface ChipProps {
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
color?: ChipColor;
|
|
6
|
+
className?: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
variant?: 'outline' | 'filled';
|
|
9
|
+
}
|
|
10
|
+
export declare const Chip: (props: ChipProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Chip';
|
package/dist/grunnmuren.es.js
CHANGED
|
@@ -31,7 +31,7 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
};
|
|
32
32
|
import classNames from "clsx";
|
|
33
33
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
34
|
-
import { useCallback, useState, useEffect, useId, forwardRef, useContext,
|
|
34
|
+
import { useCallback, useState, useEffect, useId, forwardRef, useContext, Children, isValidElement, cloneElement, createContext, useMemo, useRef } from "react";
|
|
35
35
|
var __defProp2 = Object.defineProperty;
|
|
36
36
|
var __defProps2 = Object.defineProperties;
|
|
37
37
|
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
@@ -165,6 +165,41 @@ const AlertIcon = ({
|
|
|
165
165
|
className: classNames(className, "text-orange")
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
|
+
const chipVariations = {
|
|
169
|
+
"blue-light": "bg-blue-light border-blue-light",
|
|
170
|
+
"red-light": "bg-red-light border-red-light",
|
|
171
|
+
"green-light": "bg-green-light border-green-light",
|
|
172
|
+
"orange-light": "bg-orange-light border-orange-light"
|
|
173
|
+
};
|
|
174
|
+
const iconColors = {
|
|
175
|
+
"blue-light": "text-blue-dark",
|
|
176
|
+
"red-light": "text-red",
|
|
177
|
+
"green-light": "text-green",
|
|
178
|
+
"orange-light": "text-black"
|
|
179
|
+
};
|
|
180
|
+
const Chip = (props) => {
|
|
181
|
+
const {
|
|
182
|
+
className,
|
|
183
|
+
color,
|
|
184
|
+
icon,
|
|
185
|
+
children,
|
|
186
|
+
variant = "filled"
|
|
187
|
+
} = props;
|
|
188
|
+
const chipVariation = color && chipVariations[color];
|
|
189
|
+
const iconColor = color && iconColors[color];
|
|
190
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
191
|
+
className: classNames("inline-flex items-center overflow-hidden rounded-lg border-2 font-medium", chipVariation, className),
|
|
192
|
+
children: [icon && /* @__PURE__ */ jsx("div", {
|
|
193
|
+
className: classNames("px-3 py-2", iconColor),
|
|
194
|
+
children: icon
|
|
195
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
196
|
+
className: classNames("flex-1 py-2 px-3", {
|
|
197
|
+
"bg-white": variant === "outline"
|
|
198
|
+
}),
|
|
199
|
+
children
|
|
200
|
+
})]
|
|
201
|
+
});
|
|
202
|
+
};
|
|
168
203
|
function assignRef(ref, value) {
|
|
169
204
|
if (ref == null)
|
|
170
205
|
return;
|
|
@@ -309,15 +344,19 @@ const buttonVariations = {
|
|
|
309
344
|
};
|
|
310
345
|
const Button = forwardRef((props, ref) => {
|
|
311
346
|
const _a = props, {
|
|
347
|
+
children: childrenFromProp,
|
|
312
348
|
className,
|
|
313
349
|
color: colorFromProp,
|
|
314
350
|
href,
|
|
351
|
+
loading,
|
|
315
352
|
type = "button",
|
|
316
353
|
variant = "primary"
|
|
317
354
|
} = _a, rest = __objRest(_a, [
|
|
355
|
+
"children",
|
|
318
356
|
"className",
|
|
319
357
|
"color",
|
|
320
358
|
"href",
|
|
359
|
+
"loading",
|
|
321
360
|
"type",
|
|
322
361
|
"variant"
|
|
323
362
|
]);
|
|
@@ -325,18 +364,72 @@ const Button = forwardRef((props, ref) => {
|
|
|
325
364
|
const color = colorFromProp != null ? colorFromProp : colorFromContext;
|
|
326
365
|
const buttonVariation = buttonVariations[`${color}-${variant}`];
|
|
327
366
|
const classes = classNames(className, buttonVariation, "button");
|
|
367
|
+
const children = loading ? /* @__PURE__ */ jsx(Loader, {
|
|
368
|
+
children: childrenFromProp
|
|
369
|
+
}) : childrenFromProp;
|
|
328
370
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
329
|
-
children: href ? /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({
|
|
371
|
+
children: href ? /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({
|
|
372
|
+
"aria-busy": loading ? true : void 0
|
|
373
|
+
}, rest), {
|
|
330
374
|
href,
|
|
331
375
|
ref,
|
|
332
|
-
className: classes
|
|
333
|
-
|
|
376
|
+
className: classes,
|
|
377
|
+
children
|
|
378
|
+
})) : /* @__PURE__ */ jsx("button", __spreadProps(__spreadValues({
|
|
379
|
+
"aria-busy": loading ? true : void 0
|
|
380
|
+
}, rest), {
|
|
334
381
|
type,
|
|
335
382
|
ref,
|
|
336
|
-
className: classes
|
|
383
|
+
className: classes,
|
|
384
|
+
children
|
|
337
385
|
}))
|
|
338
386
|
});
|
|
339
387
|
});
|
|
388
|
+
const Loader = (props) => {
|
|
389
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
390
|
+
children: [deeplyWrapStrings(props.children), /* @__PURE__ */ jsx("span", {
|
|
391
|
+
className: "!visible absolute top-1 bottom-1 left-1 right-1 grid place-items-center overflow-hidden bg-inherit",
|
|
392
|
+
"aria-hidden": true,
|
|
393
|
+
children: /* @__PURE__ */ jsx(LoadingIcon, {
|
|
394
|
+
className: "animate-spin"
|
|
395
|
+
})
|
|
396
|
+
})]
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
const LoadingIcon = (props) => /* @__PURE__ */ jsxs("svg", __spreadProps(__spreadValues({
|
|
400
|
+
width: "1.25em",
|
|
401
|
+
height: "1.25em",
|
|
402
|
+
fill: "none",
|
|
403
|
+
viewBox: "0 0 24 24"
|
|
404
|
+
}, props), {
|
|
405
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
406
|
+
stroke: "currentColor",
|
|
407
|
+
strokeLinecap: "round",
|
|
408
|
+
strokeWidth: 4,
|
|
409
|
+
d: "M22 12C22 10.2897 21.5613 8.60798 20.726 7.11558C19.8906 5.62318 18.6864 4.36998 17.2285 3.47575C15.7706 2.58152 14.1077 2.07615 12.3988 2.00795C10.6898 1.93975 8.99195 2.311 7.46743 3.0862C5.9429 3.86141 4.64268 5.01466 3.69102 6.43575C2.73937 7.85683 2.1681 9.49824 2.0318 11.2031C1.89551 12.908 2.19875 14.6193 2.91255 16.1735C3.62634 17.7277 4.72684 19.0729 6.10884 20.0805"
|
|
410
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
411
|
+
cx: 21,
|
|
412
|
+
cy: 18,
|
|
413
|
+
r: 2,
|
|
414
|
+
fill: "currentColor"
|
|
415
|
+
})]
|
|
416
|
+
}));
|
|
417
|
+
function deeplyWrapStrings(children) {
|
|
418
|
+
return Children.map(children, (child) => {
|
|
419
|
+
if (!isValidElement(child)) {
|
|
420
|
+
return typeof child === "string" ? /* @__PURE__ */ jsx("span", {
|
|
421
|
+
children: child
|
|
422
|
+
}) : child;
|
|
423
|
+
}
|
|
424
|
+
if (child.props.children) {
|
|
425
|
+
const props = {
|
|
426
|
+
children: deeplyWrapStrings(child.props.children)
|
|
427
|
+
};
|
|
428
|
+
child = cloneElement(child, props);
|
|
429
|
+
}
|
|
430
|
+
return child;
|
|
431
|
+
});
|
|
432
|
+
}
|
|
340
433
|
const ButtonColorContext = createContext("standard");
|
|
341
434
|
const CampaignContext = createContext(true);
|
|
342
435
|
const Campaign = (props) => {
|
|
@@ -1269,4 +1362,4 @@ const Select = forwardRef((props, ref) => {
|
|
|
1269
1362
|
})]
|
|
1270
1363
|
});
|
|
1271
1364
|
});
|
|
1272
|
-
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 };
|
|
1365
|
+
export { 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, assignRef, useBlockBackgroundColor, useComposedRefs, useFallbackId, useFormControlValidity, useMedia, usePrefersReducedMotion, useScreenMaxWidthMd };
|
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.3.0",
|
|
4
4
|
"description": "OBOS Grunnmuren design system React components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@babel/core": "7.18.10",
|
|
21
|
-
"@obosbbl/grunnmuren-tailwind": "0.
|
|
21
|
+
"@obosbbl/grunnmuren-tailwind": "0.6.0",
|
|
22
22
|
"@storybook/addon-controls": "6.5.10",
|
|
23
23
|
"@storybook/addon-docs": "6.5.10",
|
|
24
24
|
"@storybook/addon-postcss": "2.0.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"webpack": "5.74.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@obosbbl/grunnmuren-icons": "^0.
|
|
41
|
+
"@obosbbl/grunnmuren-icons": "^0.4.0",
|
|
42
42
|
"clsx": "1.2.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@obosbbl/grunnmuren-tailwind": "^0.
|
|
45
|
+
"@obosbbl/grunnmuren-tailwind": "^0.6.0",
|
|
46
46
|
"react": "^18"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|