@cerberus-design/react 0.3.2 → 0.4.0-next-127992f
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/build/legacy/_tsup-dts-rollup.d.ts +55 -0
- package/build/legacy/chunk-5TBINKAO.js +36 -0
- package/build/legacy/chunk-5TBINKAO.js.map +1 -0
- package/build/legacy/{chunk-BPIYUAYS.js → chunk-NIMWIOIA.js} +6 -3
- package/build/legacy/chunk-NIMWIOIA.js.map +1 -0
- package/build/legacy/chunk-ULXTQXVY.js +61 -0
- package/build/legacy/chunk-ULXTQXVY.js.map +1 -0
- package/build/legacy/components/IconButton.js +1 -1
- package/build/legacy/components/Tag.d.ts +3 -0
- package/build/legacy/components/Tag.js +8 -0
- package/build/legacy/components/Tag.js.map +1 -0
- package/build/legacy/components/Textarea.d.ts +2 -0
- package/build/legacy/components/Textarea.js +9 -0
- package/build/legacy/components/Textarea.js.map +1 -0
- package/build/legacy/index.d.ts +5 -0
- package/build/legacy/index.js +9 -1
- package/build/modern/_tsup-dts-rollup.d.ts +55 -0
- package/build/modern/chunk-5TBINKAO.js +36 -0
- package/build/modern/chunk-5TBINKAO.js.map +1 -0
- package/build/modern/{chunk-BPIYUAYS.js → chunk-NIMWIOIA.js} +6 -3
- package/build/modern/chunk-NIMWIOIA.js.map +1 -0
- package/build/modern/chunk-ULXTQXVY.js +61 -0
- package/build/modern/chunk-ULXTQXVY.js.map +1 -0
- package/build/modern/components/IconButton.js +1 -1
- package/build/modern/components/Tag.d.ts +3 -0
- package/build/modern/components/Tag.js +8 -0
- package/build/modern/components/Tag.js.map +1 -0
- package/build/modern/components/Textarea.d.ts +2 -0
- package/build/modern/components/Textarea.js +9 -0
- package/build/modern/components/Textarea.js.map +1 -0
- package/build/modern/index.d.ts +5 -0
- package/build/modern/index.js +9 -1
- package/package.json +1 -1
- package/src/components/IconButton.tsx +6 -1
- package/src/components/Tag.tsx +82 -0
- package/src/components/Textarea.tsx +45 -0
- package/src/index.ts +2 -0
- package/build/legacy/chunk-BPIYUAYS.js.map +0 -1
- package/build/modern/chunk-BPIYUAYS.js.map +0 -1
|
@@ -9,6 +9,8 @@ import { MutableRefObject } from 'react';
|
|
|
9
9
|
import { PropsWithChildren } from 'react';
|
|
10
10
|
import { ReactNode } from 'react';
|
|
11
11
|
import { RefObject } from 'react';
|
|
12
|
+
import { Sentiment } from '@cerberus/panda-preset';
|
|
13
|
+
import type { TextareaHTMLAttributes } from 'react';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* A component that allows the user to perform actions
|
|
@@ -30,6 +32,15 @@ declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
30
32
|
export { ButtonProps }
|
|
31
33
|
export { ButtonProps as ButtonProps_alias_1 }
|
|
32
34
|
|
|
35
|
+
declare interface ClickableTagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
36
|
+
palette?: Sentiment;
|
|
37
|
+
shape?: 'pill';
|
|
38
|
+
onClick: () => void;
|
|
39
|
+
usage?: 'filled';
|
|
40
|
+
}
|
|
41
|
+
export { ClickableTagProps }
|
|
42
|
+
export { ClickableTagProps as ClickableTagProps_alias_1 }
|
|
43
|
+
|
|
33
44
|
declare type ColorModes = 'light' | 'dark';
|
|
34
45
|
export { ColorModes }
|
|
35
46
|
export { ColorModes as ColorModes_alias_1 }
|
|
@@ -111,6 +122,8 @@ declare interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement
|
|
|
111
122
|
palette?: ButtonProps['palette'];
|
|
112
123
|
usage?: IconButtonUsage;
|
|
113
124
|
shape?: 'circle';
|
|
125
|
+
size?: 'sm' | 'lg';
|
|
126
|
+
tooltipPosition?: 'top' | 'bottom' | 'left' | 'right';
|
|
114
127
|
}
|
|
115
128
|
export { IconButtonProps }
|
|
116
129
|
export { IconButtonProps as IconButtonProps_alias_1 }
|
|
@@ -401,6 +414,48 @@ declare interface TabsProps {
|
|
|
401
414
|
export { TabsProps }
|
|
402
415
|
export { TabsProps as TabsProps_alias_1 }
|
|
403
416
|
|
|
417
|
+
/**
|
|
418
|
+
* The Tag component is used to display a meta descriptions.
|
|
419
|
+
* @example
|
|
420
|
+
* ```tsx
|
|
421
|
+
* <Tag>Tag</Tag>
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
declare function Tag(props: PropsWithChildren<TagProps | ClickableTagProps>): JSX.Element;
|
|
425
|
+
export { Tag }
|
|
426
|
+
export { Tag as Tag_alias_1 }
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* This module contains the tag component.
|
|
430
|
+
* @module
|
|
431
|
+
*/
|
|
432
|
+
declare interface TagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
433
|
+
palette?: Sentiment;
|
|
434
|
+
shape?: 'rounded' | 'pill';
|
|
435
|
+
usage?: 'filled' | 'outline';
|
|
436
|
+
}
|
|
437
|
+
export { TagProps }
|
|
438
|
+
export { TagProps as TagProps_alias_1 }
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* A component that allows the user to input large blocks of text.
|
|
442
|
+
* @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Textarea.tsx
|
|
443
|
+
*/
|
|
444
|
+
declare function Textarea(props: TextareaProps): JSX.Element;
|
|
445
|
+
export { Textarea }
|
|
446
|
+
export { Textarea as Textarea_alias_1 }
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* This module contains the Textarea component.
|
|
450
|
+
* @module
|
|
451
|
+
*/
|
|
452
|
+
declare interface TextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'> {
|
|
453
|
+
describedBy?: string;
|
|
454
|
+
id: string;
|
|
455
|
+
}
|
|
456
|
+
export { TextareaProps }
|
|
457
|
+
export { TextareaProps as TextareaProps_alias_1 }
|
|
458
|
+
|
|
404
459
|
declare const THEME_KEY = "cerberus-theme";
|
|
405
460
|
export { THEME_KEY }
|
|
406
461
|
export { THEME_KEY as THEME_KEY_alias_1 }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFieldContext
|
|
3
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Textarea.tsx
|
|
6
|
+
import { css, cx } from "@cerberus/styled-system/css";
|
|
7
|
+
import { input } from "@cerberus/styled-system/recipes";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function Textarea(props) {
|
|
10
|
+
const { describedBy, ...nativeProps } = props;
|
|
11
|
+
const { invalid, ...fieldState } = useFieldContext();
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
"textarea",
|
|
14
|
+
{
|
|
15
|
+
...nativeProps,
|
|
16
|
+
...fieldState,
|
|
17
|
+
...describedBy && { "aria-describedby": describedBy },
|
|
18
|
+
...invalid && { "aria-invalid": true },
|
|
19
|
+
className: cx(
|
|
20
|
+
props.className,
|
|
21
|
+
input().input,
|
|
22
|
+
css({
|
|
23
|
+
pxi: "2",
|
|
24
|
+
py: "2",
|
|
25
|
+
resize: "vertical"
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
rows: 4
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
Textarea
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-5TBINKAO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Textarea.tsx"],"sourcesContent":["'use client'\n\nimport type { TextareaHTMLAttributes } from 'react'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { useFieldContext } from '../context/field'\n\n/**\n * This module contains the Textarea component.\n * @module\n */\n\nexport interface TextareaProps\n extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'> {\n describedBy?: string\n id: string\n}\n\n/**\n * A component that allows the user to input large blocks of text.\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Textarea.tsx\n */\nexport function Textarea(props: TextareaProps): JSX.Element {\n const { describedBy, ...nativeProps } = props\n const { invalid, ...fieldState } = useFieldContext()\n\n return (\n <textarea\n {...nativeProps}\n {...fieldState}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n className={cx(\n props.className,\n input().input,\n css({\n pxi: '2',\n py: '2',\n resize: 'vertical',\n }),\n )}\n rows={4}\n />\n )\n}\n"],"mappings":";;;;;AAGA,SAAS,KAAK,UAAU;AACxB,SAAS,aAAa;AAuBlB;AALG,SAAS,SAAS,OAAmC;AAC1D,QAAM,EAAE,aAAa,GAAG,YAAY,IAAI;AACxC,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI,gBAAgB;AAEnD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,MACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,MACvC,WAAW;AAAA,QACT,MAAM;AAAA,QACN,MAAM,EAAE;AAAA,QACR,IAAI;AAAA,UACF,KAAK;AAAA,UACL,IAAI;AAAA,UACJ,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AAAA,MACA,MAAM;AAAA;AAAA,EACR;AAEJ;","names":[]}
|
|
@@ -3,17 +3,20 @@ import { cx } from "@cerberus/styled-system/css";
|
|
|
3
3
|
import { iconButton } from "@cerberus/styled-system/recipes";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
function IconButton(props) {
|
|
6
|
-
const { ariaLabel, palette, usage, ...nativeProps } = props;
|
|
6
|
+
const { ariaLabel, palette, usage, size, ...nativeProps } = props;
|
|
7
7
|
return /* @__PURE__ */ jsx(
|
|
8
8
|
"button",
|
|
9
9
|
{
|
|
10
10
|
...nativeProps,
|
|
11
|
+
"data-tooltip": true,
|
|
12
|
+
"data-position": props.tooltipPosition ?? "top",
|
|
11
13
|
"aria-label": ariaLabel ?? "Icon Button",
|
|
12
14
|
className: cx(
|
|
13
15
|
nativeProps.className,
|
|
14
16
|
iconButton({
|
|
15
17
|
palette,
|
|
16
|
-
usage
|
|
18
|
+
usage,
|
|
19
|
+
size
|
|
17
20
|
})
|
|
18
21
|
)
|
|
19
22
|
}
|
|
@@ -23,4 +26,4 @@ function IconButton(props) {
|
|
|
23
26
|
export {
|
|
24
27
|
IconButton
|
|
25
28
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-NIMWIOIA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/IconButton.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { iconButton } from '@cerberus/styled-system/recipes'\nimport type { ButtonProps } from './Button'\n\n/**\n * This module contains the Icon Button component.\n * @module\n */\n\nexport type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>\nexport interface IconButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n ariaLabel: string\n palette?: ButtonProps['palette']\n usage?: IconButtonUsage\n shape?: 'circle'\n size?: 'sm' | 'lg'\n tooltipPosition?: 'top' | 'bottom' | 'left' | 'right'\n}\n\n/**\n * A component that allows the user to perform actions using an icon\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/IconButton.tsx\n */\nexport function IconButton(props: IconButtonProps): JSX.Element {\n const { ariaLabel, palette, usage, size, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n data-tooltip\n data-position={props.tooltipPosition ?? 'top'}\n aria-label={ariaLabel ?? 'Icon Button'}\n className={cx(\n nativeProps.className,\n iconButton({\n palette,\n usage,\n size,\n }),\n )}\n />\n )\n}\n"],"mappings":";AACA,SAAS,UAAU;AACnB,SAAS,kBAAkB;AA0BvB;AAHG,SAAS,WAAW,OAAqC;AAC9D,QAAM,EAAE,WAAW,SAAS,OAAO,MAAM,GAAG,YAAY,IAAI;AAC5D,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,gBAAY;AAAA,MACZ,iBAAe,MAAM,mBAAmB;AAAA,MACxC,cAAY,aAAa;AAAA,MACzB,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Show
|
|
3
|
+
} from "./chunk-R4H3352X.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Tag.tsx
|
|
6
|
+
import { Close } from "@cerberus/icons";
|
|
7
|
+
import { css, cx } from "@cerberus/styled-system/css";
|
|
8
|
+
import { iconButton, tag } from "@cerberus/styled-system/recipes";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function Tag(props) {
|
|
11
|
+
const {
|
|
12
|
+
palette: initPalette,
|
|
13
|
+
shape: initShape,
|
|
14
|
+
onClick,
|
|
15
|
+
usage,
|
|
16
|
+
...nativeProps
|
|
17
|
+
} = props;
|
|
18
|
+
const isClosable = Boolean(onClick);
|
|
19
|
+
const shape = isClosable ? "pill" : initShape;
|
|
20
|
+
const palette = isClosable ? "action" : initPalette;
|
|
21
|
+
const closableStyles = isClosable ? css({
|
|
22
|
+
bgColor: "action.bg.active",
|
|
23
|
+
paddingInlineEnd: "0"
|
|
24
|
+
}) : "";
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
"span",
|
|
27
|
+
{
|
|
28
|
+
...nativeProps,
|
|
29
|
+
className: cx(
|
|
30
|
+
nativeProps.className,
|
|
31
|
+
tag({
|
|
32
|
+
palette,
|
|
33
|
+
shape,
|
|
34
|
+
usage
|
|
35
|
+
}),
|
|
36
|
+
closableStyles
|
|
37
|
+
),
|
|
38
|
+
children: [
|
|
39
|
+
props.children,
|
|
40
|
+
/* @__PURE__ */ jsx(Show, { when: isClosable, children: /* @__PURE__ */ jsx(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
"aria-label": "Close",
|
|
44
|
+
className: iconButton({
|
|
45
|
+
palette: "action",
|
|
46
|
+
usage: "filled",
|
|
47
|
+
size: "sm"
|
|
48
|
+
}),
|
|
49
|
+
onClick,
|
|
50
|
+
children: /* @__PURE__ */ jsx(Close, {})
|
|
51
|
+
}
|
|
52
|
+
) })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
Tag
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=chunk-ULXTQXVY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["import type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { Close } from '@cerberus/icons'\nimport { type Sentiment } from '@cerberus/panda-preset'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { iconButton, tag } from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport interface TagProps extends HTMLAttributes<HTMLSpanElement> {\n palette?: Sentiment\n shape?: 'rounded' | 'pill'\n usage?: 'filled' | 'outline'\n}\nexport interface ClickableTagProps extends HTMLAttributes<HTMLSpanElement> {\n palette?: Sentiment\n shape?: 'pill'\n onClick: () => void\n usage?: 'filled'\n}\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(\n props: PropsWithChildren<TagProps | ClickableTagProps>,\n): JSX.Element {\n const {\n palette: initPalette,\n shape: initShape,\n onClick,\n usage,\n ...nativeProps\n } = props\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const palette = isClosable ? 'action' : initPalette\n const closableStyles = isClosable\n ? css({\n bgColor: 'action.bg.active',\n paddingInlineEnd: '0',\n })\n : ''\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n"],"mappings":";;;;;AACA,SAAS,aAAa;AAGtB,SAAS,KAAK,UAAU;AACxB,SAAS,YAAY,WAAW;AA+C5B,SAwBM,KAxBN;AArBG,SAAS,IACd,OACa;AACb,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,UAAU,aAAa,WAAW;AACxC,QAAM,iBAAiB,aACnB,IAAI;AAAA,IACF,SAAS;AAAA,IACT,kBAAkB;AAAA,EACpB,CAAC,IACD;AAEJ,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export { TabList } from './_tsup-dts-rollup';
|
|
|
22
22
|
export { TabListProps } from './_tsup-dts-rollup';
|
|
23
23
|
export { TabPanel } from './_tsup-dts-rollup';
|
|
24
24
|
export { TabPanelProps } from './_tsup-dts-rollup';
|
|
25
|
+
export { Tag } from './_tsup-dts-rollup';
|
|
26
|
+
export { TagProps } from './_tsup-dts-rollup';
|
|
27
|
+
export { ClickableTagProps } from './_tsup-dts-rollup';
|
|
28
|
+
export { Textarea } from './_tsup-dts-rollup';
|
|
29
|
+
export { TextareaProps } from './_tsup-dts-rollup';
|
|
25
30
|
export { Show } from './_tsup-dts-rollup';
|
|
26
31
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
27
32
|
export { Field } from './_tsup-dts-rollup';
|
package/build/legacy/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TabPanel
|
|
3
3
|
} from "./chunk-SVZU6LPF.js";
|
|
4
|
+
import {
|
|
5
|
+
Tag
|
|
6
|
+
} from "./chunk-ULXTQXVY.js";
|
|
7
|
+
import {
|
|
8
|
+
Textarea
|
|
9
|
+
} from "./chunk-5TBINKAO.js";
|
|
4
10
|
import {
|
|
5
11
|
Input
|
|
6
12
|
} from "./chunk-LD5ZV46F.js";
|
|
@@ -61,7 +67,7 @@ import {
|
|
|
61
67
|
} from "./chunk-ZAU4JVLL.js";
|
|
62
68
|
import {
|
|
63
69
|
IconButton
|
|
64
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-NIMWIOIA.js";
|
|
65
71
|
export {
|
|
66
72
|
Button,
|
|
67
73
|
Field,
|
|
@@ -81,6 +87,8 @@ export {
|
|
|
81
87
|
TabPanel,
|
|
82
88
|
Tabs,
|
|
83
89
|
TabsContext,
|
|
90
|
+
Tag,
|
|
91
|
+
Textarea,
|
|
84
92
|
ThemeProvider,
|
|
85
93
|
createNavTriggerProps,
|
|
86
94
|
getPosition,
|
|
@@ -9,6 +9,8 @@ import { MutableRefObject } from 'react';
|
|
|
9
9
|
import { PropsWithChildren } from 'react';
|
|
10
10
|
import { ReactNode } from 'react';
|
|
11
11
|
import { RefObject } from 'react';
|
|
12
|
+
import { Sentiment } from '@cerberus/panda-preset';
|
|
13
|
+
import type { TextareaHTMLAttributes } from 'react';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* A component that allows the user to perform actions
|
|
@@ -30,6 +32,15 @@ declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
30
32
|
export { ButtonProps }
|
|
31
33
|
export { ButtonProps as ButtonProps_alias_1 }
|
|
32
34
|
|
|
35
|
+
declare interface ClickableTagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
36
|
+
palette?: Sentiment;
|
|
37
|
+
shape?: 'pill';
|
|
38
|
+
onClick: () => void;
|
|
39
|
+
usage?: 'filled';
|
|
40
|
+
}
|
|
41
|
+
export { ClickableTagProps }
|
|
42
|
+
export { ClickableTagProps as ClickableTagProps_alias_1 }
|
|
43
|
+
|
|
33
44
|
declare type ColorModes = 'light' | 'dark';
|
|
34
45
|
export { ColorModes }
|
|
35
46
|
export { ColorModes as ColorModes_alias_1 }
|
|
@@ -111,6 +122,8 @@ declare interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement
|
|
|
111
122
|
palette?: ButtonProps['palette'];
|
|
112
123
|
usage?: IconButtonUsage;
|
|
113
124
|
shape?: 'circle';
|
|
125
|
+
size?: 'sm' | 'lg';
|
|
126
|
+
tooltipPosition?: 'top' | 'bottom' | 'left' | 'right';
|
|
114
127
|
}
|
|
115
128
|
export { IconButtonProps }
|
|
116
129
|
export { IconButtonProps as IconButtonProps_alias_1 }
|
|
@@ -401,6 +414,48 @@ declare interface TabsProps {
|
|
|
401
414
|
export { TabsProps }
|
|
402
415
|
export { TabsProps as TabsProps_alias_1 }
|
|
403
416
|
|
|
417
|
+
/**
|
|
418
|
+
* The Tag component is used to display a meta descriptions.
|
|
419
|
+
* @example
|
|
420
|
+
* ```tsx
|
|
421
|
+
* <Tag>Tag</Tag>
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
declare function Tag(props: PropsWithChildren<TagProps | ClickableTagProps>): JSX.Element;
|
|
425
|
+
export { Tag }
|
|
426
|
+
export { Tag as Tag_alias_1 }
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* This module contains the tag component.
|
|
430
|
+
* @module
|
|
431
|
+
*/
|
|
432
|
+
declare interface TagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
433
|
+
palette?: Sentiment;
|
|
434
|
+
shape?: 'rounded' | 'pill';
|
|
435
|
+
usage?: 'filled' | 'outline';
|
|
436
|
+
}
|
|
437
|
+
export { TagProps }
|
|
438
|
+
export { TagProps as TagProps_alias_1 }
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* A component that allows the user to input large blocks of text.
|
|
442
|
+
* @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Textarea.tsx
|
|
443
|
+
*/
|
|
444
|
+
declare function Textarea(props: TextareaProps): JSX.Element;
|
|
445
|
+
export { Textarea }
|
|
446
|
+
export { Textarea as Textarea_alias_1 }
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* This module contains the Textarea component.
|
|
450
|
+
* @module
|
|
451
|
+
*/
|
|
452
|
+
declare interface TextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'> {
|
|
453
|
+
describedBy?: string;
|
|
454
|
+
id: string;
|
|
455
|
+
}
|
|
456
|
+
export { TextareaProps }
|
|
457
|
+
export { TextareaProps as TextareaProps_alias_1 }
|
|
458
|
+
|
|
404
459
|
declare const THEME_KEY = "cerberus-theme";
|
|
405
460
|
export { THEME_KEY }
|
|
406
461
|
export { THEME_KEY as THEME_KEY_alias_1 }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFieldContext
|
|
3
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Textarea.tsx
|
|
6
|
+
import { css, cx } from "@cerberus/styled-system/css";
|
|
7
|
+
import { input } from "@cerberus/styled-system/recipes";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function Textarea(props) {
|
|
10
|
+
const { describedBy, ...nativeProps } = props;
|
|
11
|
+
const { invalid, ...fieldState } = useFieldContext();
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
"textarea",
|
|
14
|
+
{
|
|
15
|
+
...nativeProps,
|
|
16
|
+
...fieldState,
|
|
17
|
+
...describedBy && { "aria-describedby": describedBy },
|
|
18
|
+
...invalid && { "aria-invalid": true },
|
|
19
|
+
className: cx(
|
|
20
|
+
props.className,
|
|
21
|
+
input().input,
|
|
22
|
+
css({
|
|
23
|
+
pxi: "2",
|
|
24
|
+
py: "2",
|
|
25
|
+
resize: "vertical"
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
rows: 4
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
Textarea
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-5TBINKAO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Textarea.tsx"],"sourcesContent":["'use client'\n\nimport type { TextareaHTMLAttributes } from 'react'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { useFieldContext } from '../context/field'\n\n/**\n * This module contains the Textarea component.\n * @module\n */\n\nexport interface TextareaProps\n extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'> {\n describedBy?: string\n id: string\n}\n\n/**\n * A component that allows the user to input large blocks of text.\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Textarea.tsx\n */\nexport function Textarea(props: TextareaProps): JSX.Element {\n const { describedBy, ...nativeProps } = props\n const { invalid, ...fieldState } = useFieldContext()\n\n return (\n <textarea\n {...nativeProps}\n {...fieldState}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n className={cx(\n props.className,\n input().input,\n css({\n pxi: '2',\n py: '2',\n resize: 'vertical',\n }),\n )}\n rows={4}\n />\n )\n}\n"],"mappings":";;;;;AAGA,SAAS,KAAK,UAAU;AACxB,SAAS,aAAa;AAuBlB;AALG,SAAS,SAAS,OAAmC;AAC1D,QAAM,EAAE,aAAa,GAAG,YAAY,IAAI;AACxC,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI,gBAAgB;AAEnD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,MACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,MACvC,WAAW;AAAA,QACT,MAAM;AAAA,QACN,MAAM,EAAE;AAAA,QACR,IAAI;AAAA,UACF,KAAK;AAAA,UACL,IAAI;AAAA,UACJ,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AAAA,MACA,MAAM;AAAA;AAAA,EACR;AAEJ;","names":[]}
|
|
@@ -3,17 +3,20 @@ import { cx } from "@cerberus/styled-system/css";
|
|
|
3
3
|
import { iconButton } from "@cerberus/styled-system/recipes";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
function IconButton(props) {
|
|
6
|
-
const { ariaLabel, palette, usage, ...nativeProps } = props;
|
|
6
|
+
const { ariaLabel, palette, usage, size, ...nativeProps } = props;
|
|
7
7
|
return /* @__PURE__ */ jsx(
|
|
8
8
|
"button",
|
|
9
9
|
{
|
|
10
10
|
...nativeProps,
|
|
11
|
+
"data-tooltip": true,
|
|
12
|
+
"data-position": props.tooltipPosition ?? "top",
|
|
11
13
|
"aria-label": ariaLabel ?? "Icon Button",
|
|
12
14
|
className: cx(
|
|
13
15
|
nativeProps.className,
|
|
14
16
|
iconButton({
|
|
15
17
|
palette,
|
|
16
|
-
usage
|
|
18
|
+
usage,
|
|
19
|
+
size
|
|
17
20
|
})
|
|
18
21
|
)
|
|
19
22
|
}
|
|
@@ -23,4 +26,4 @@ function IconButton(props) {
|
|
|
23
26
|
export {
|
|
24
27
|
IconButton
|
|
25
28
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-NIMWIOIA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/IconButton.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { iconButton } from '@cerberus/styled-system/recipes'\nimport type { ButtonProps } from './Button'\n\n/**\n * This module contains the Icon Button component.\n * @module\n */\n\nexport type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>\nexport interface IconButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n ariaLabel: string\n palette?: ButtonProps['palette']\n usage?: IconButtonUsage\n shape?: 'circle'\n size?: 'sm' | 'lg'\n tooltipPosition?: 'top' | 'bottom' | 'left' | 'right'\n}\n\n/**\n * A component that allows the user to perform actions using an icon\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/IconButton.tsx\n */\nexport function IconButton(props: IconButtonProps): JSX.Element {\n const { ariaLabel, palette, usage, size, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n data-tooltip\n data-position={props.tooltipPosition ?? 'top'}\n aria-label={ariaLabel ?? 'Icon Button'}\n className={cx(\n nativeProps.className,\n iconButton({\n palette,\n usage,\n size,\n }),\n )}\n />\n )\n}\n"],"mappings":";AACA,SAAS,UAAU;AACnB,SAAS,kBAAkB;AA0BvB;AAHG,SAAS,WAAW,OAAqC;AAC9D,QAAM,EAAE,WAAW,SAAS,OAAO,MAAM,GAAG,YAAY,IAAI;AAC5D,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,gBAAY;AAAA,MACZ,iBAAe,MAAM,mBAAmB;AAAA,MACxC,cAAY,aAAa;AAAA,MACzB,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Show
|
|
3
|
+
} from "./chunk-R4H3352X.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Tag.tsx
|
|
6
|
+
import { Close } from "@cerberus/icons";
|
|
7
|
+
import { css, cx } from "@cerberus/styled-system/css";
|
|
8
|
+
import { iconButton, tag } from "@cerberus/styled-system/recipes";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function Tag(props) {
|
|
11
|
+
const {
|
|
12
|
+
palette: initPalette,
|
|
13
|
+
shape: initShape,
|
|
14
|
+
onClick,
|
|
15
|
+
usage,
|
|
16
|
+
...nativeProps
|
|
17
|
+
} = props;
|
|
18
|
+
const isClosable = Boolean(onClick);
|
|
19
|
+
const shape = isClosable ? "pill" : initShape;
|
|
20
|
+
const palette = isClosable ? "action" : initPalette;
|
|
21
|
+
const closableStyles = isClosable ? css({
|
|
22
|
+
bgColor: "action.bg.active",
|
|
23
|
+
paddingInlineEnd: "0"
|
|
24
|
+
}) : "";
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
"span",
|
|
27
|
+
{
|
|
28
|
+
...nativeProps,
|
|
29
|
+
className: cx(
|
|
30
|
+
nativeProps.className,
|
|
31
|
+
tag({
|
|
32
|
+
palette,
|
|
33
|
+
shape,
|
|
34
|
+
usage
|
|
35
|
+
}),
|
|
36
|
+
closableStyles
|
|
37
|
+
),
|
|
38
|
+
children: [
|
|
39
|
+
props.children,
|
|
40
|
+
/* @__PURE__ */ jsx(Show, { when: isClosable, children: /* @__PURE__ */ jsx(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
"aria-label": "Close",
|
|
44
|
+
className: iconButton({
|
|
45
|
+
palette: "action",
|
|
46
|
+
usage: "filled",
|
|
47
|
+
size: "sm"
|
|
48
|
+
}),
|
|
49
|
+
onClick,
|
|
50
|
+
children: /* @__PURE__ */ jsx(Close, {})
|
|
51
|
+
}
|
|
52
|
+
) })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
Tag
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=chunk-ULXTQXVY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["import type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { Close } from '@cerberus/icons'\nimport { type Sentiment } from '@cerberus/panda-preset'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { iconButton, tag } from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport interface TagProps extends HTMLAttributes<HTMLSpanElement> {\n palette?: Sentiment\n shape?: 'rounded' | 'pill'\n usage?: 'filled' | 'outline'\n}\nexport interface ClickableTagProps extends HTMLAttributes<HTMLSpanElement> {\n palette?: Sentiment\n shape?: 'pill'\n onClick: () => void\n usage?: 'filled'\n}\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(\n props: PropsWithChildren<TagProps | ClickableTagProps>,\n): JSX.Element {\n const {\n palette: initPalette,\n shape: initShape,\n onClick,\n usage,\n ...nativeProps\n } = props\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const palette = isClosable ? 'action' : initPalette\n const closableStyles = isClosable\n ? css({\n bgColor: 'action.bg.active',\n paddingInlineEnd: '0',\n })\n : ''\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n"],"mappings":";;;;;AACA,SAAS,aAAa;AAGtB,SAAS,KAAK,UAAU;AACxB,SAAS,YAAY,WAAW;AA+C5B,SAwBM,KAxBN;AArBG,SAAS,IACd,OACa;AACb,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,UAAU,aAAa,WAAW;AACxC,QAAM,iBAAiB,aACnB,IAAI;AAAA,IACF,SAAS;AAAA,IACT,kBAAkB;AAAA,EACpB,CAAC,IACD;AAEJ,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/modern/index.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export { TabList } from './_tsup-dts-rollup';
|
|
|
22
22
|
export { TabListProps } from './_tsup-dts-rollup';
|
|
23
23
|
export { TabPanel } from './_tsup-dts-rollup';
|
|
24
24
|
export { TabPanelProps } from './_tsup-dts-rollup';
|
|
25
|
+
export { Tag } from './_tsup-dts-rollup';
|
|
26
|
+
export { TagProps } from './_tsup-dts-rollup';
|
|
27
|
+
export { ClickableTagProps } from './_tsup-dts-rollup';
|
|
28
|
+
export { Textarea } from './_tsup-dts-rollup';
|
|
29
|
+
export { TextareaProps } from './_tsup-dts-rollup';
|
|
25
30
|
export { Show } from './_tsup-dts-rollup';
|
|
26
31
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
27
32
|
export { Field } from './_tsup-dts-rollup';
|
package/build/modern/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TabPanel
|
|
3
3
|
} from "./chunk-SVZU6LPF.js";
|
|
4
|
+
import {
|
|
5
|
+
Tag
|
|
6
|
+
} from "./chunk-ULXTQXVY.js";
|
|
7
|
+
import {
|
|
8
|
+
Textarea
|
|
9
|
+
} from "./chunk-5TBINKAO.js";
|
|
4
10
|
import {
|
|
5
11
|
Input
|
|
6
12
|
} from "./chunk-LD5ZV46F.js";
|
|
@@ -61,7 +67,7 @@ import {
|
|
|
61
67
|
} from "./chunk-ZAU4JVLL.js";
|
|
62
68
|
import {
|
|
63
69
|
IconButton
|
|
64
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-NIMWIOIA.js";
|
|
65
71
|
export {
|
|
66
72
|
Button,
|
|
67
73
|
Field,
|
|
@@ -81,6 +87,8 @@ export {
|
|
|
81
87
|
TabPanel,
|
|
82
88
|
Tabs,
|
|
83
89
|
TabsContext,
|
|
90
|
+
Tag,
|
|
91
|
+
Textarea,
|
|
84
92
|
ThemeProvider,
|
|
85
93
|
createNavTriggerProps,
|
|
86
94
|
getPosition,
|
package/package.json
CHANGED
|
@@ -15,6 +15,8 @@ export interface IconButtonProps
|
|
|
15
15
|
palette?: ButtonProps['palette']
|
|
16
16
|
usage?: IconButtonUsage
|
|
17
17
|
shape?: 'circle'
|
|
18
|
+
size?: 'sm' | 'lg'
|
|
19
|
+
tooltipPosition?: 'top' | 'bottom' | 'left' | 'right'
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -22,16 +24,19 @@ export interface IconButtonProps
|
|
|
22
24
|
* @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/IconButton.tsx
|
|
23
25
|
*/
|
|
24
26
|
export function IconButton(props: IconButtonProps): JSX.Element {
|
|
25
|
-
const { ariaLabel, palette, usage, ...nativeProps } = props
|
|
27
|
+
const { ariaLabel, palette, usage, size, ...nativeProps } = props
|
|
26
28
|
return (
|
|
27
29
|
<button
|
|
28
30
|
{...nativeProps}
|
|
31
|
+
data-tooltip
|
|
32
|
+
data-position={props.tooltipPosition ?? 'top'}
|
|
29
33
|
aria-label={ariaLabel ?? 'Icon Button'}
|
|
30
34
|
className={cx(
|
|
31
35
|
nativeProps.className,
|
|
32
36
|
iconButton({
|
|
33
37
|
palette,
|
|
34
38
|
usage,
|
|
39
|
+
size,
|
|
35
40
|
}),
|
|
36
41
|
)}
|
|
37
42
|
/>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { HTMLAttributes, PropsWithChildren } from 'react'
|
|
2
|
+
import { Close } from '@cerberus/icons'
|
|
3
|
+
import { type Sentiment } from '@cerberus/panda-preset'
|
|
4
|
+
import { Show } from './Show'
|
|
5
|
+
import { css, cx } from '@cerberus/styled-system/css'
|
|
6
|
+
import { iconButton, tag } from '@cerberus/styled-system/recipes'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This module contains the tag component.
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
14
|
+
palette?: Sentiment
|
|
15
|
+
shape?: 'rounded' | 'pill'
|
|
16
|
+
usage?: 'filled' | 'outline'
|
|
17
|
+
}
|
|
18
|
+
export interface ClickableTagProps extends HTMLAttributes<HTMLSpanElement> {
|
|
19
|
+
palette?: Sentiment
|
|
20
|
+
shape?: 'pill'
|
|
21
|
+
onClick: () => void
|
|
22
|
+
usage?: 'filled'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The Tag component is used to display a meta descriptions.
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Tag>Tag</Tag>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function Tag(
|
|
33
|
+
props: PropsWithChildren<TagProps | ClickableTagProps>,
|
|
34
|
+
): JSX.Element {
|
|
35
|
+
const {
|
|
36
|
+
palette: initPalette,
|
|
37
|
+
shape: initShape,
|
|
38
|
+
onClick,
|
|
39
|
+
usage,
|
|
40
|
+
...nativeProps
|
|
41
|
+
} = props
|
|
42
|
+
const isClosable = Boolean(onClick)
|
|
43
|
+
const shape = isClosable ? 'pill' : initShape
|
|
44
|
+
const palette = isClosable ? 'action' : initPalette
|
|
45
|
+
const closableStyles = isClosable
|
|
46
|
+
? css({
|
|
47
|
+
bgColor: 'action.bg.active',
|
|
48
|
+
paddingInlineEnd: '0',
|
|
49
|
+
})
|
|
50
|
+
: ''
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<span
|
|
54
|
+
{...nativeProps}
|
|
55
|
+
className={cx(
|
|
56
|
+
nativeProps.className,
|
|
57
|
+
tag({
|
|
58
|
+
palette,
|
|
59
|
+
shape,
|
|
60
|
+
usage,
|
|
61
|
+
}),
|
|
62
|
+
closableStyles,
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
{props.children}
|
|
66
|
+
|
|
67
|
+
<Show when={isClosable}>
|
|
68
|
+
<button
|
|
69
|
+
aria-label="Close"
|
|
70
|
+
className={iconButton({
|
|
71
|
+
palette: 'action',
|
|
72
|
+
usage: 'filled',
|
|
73
|
+
size: 'sm',
|
|
74
|
+
})}
|
|
75
|
+
onClick={onClick}
|
|
76
|
+
>
|
|
77
|
+
<Close />
|
|
78
|
+
</button>
|
|
79
|
+
</Show>
|
|
80
|
+
</span>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { TextareaHTMLAttributes } from 'react'
|
|
4
|
+
import { css, cx } from '@cerberus/styled-system/css'
|
|
5
|
+
import { input } from '@cerberus/styled-system/recipes'
|
|
6
|
+
import { useFieldContext } from '../context/field'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This module contains the Textarea component.
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface TextareaProps
|
|
14
|
+
extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'> {
|
|
15
|
+
describedBy?: string
|
|
16
|
+
id: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A component that allows the user to input large blocks of text.
|
|
21
|
+
* @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Textarea.tsx
|
|
22
|
+
*/
|
|
23
|
+
export function Textarea(props: TextareaProps): JSX.Element {
|
|
24
|
+
const { describedBy, ...nativeProps } = props
|
|
25
|
+
const { invalid, ...fieldState } = useFieldContext()
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<textarea
|
|
29
|
+
{...nativeProps}
|
|
30
|
+
{...fieldState}
|
|
31
|
+
{...(describedBy && { 'aria-describedby': describedBy })}
|
|
32
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
33
|
+
className={cx(
|
|
34
|
+
props.className,
|
|
35
|
+
input().input,
|
|
36
|
+
css({
|
|
37
|
+
pxi: '2',
|
|
38
|
+
py: '2',
|
|
39
|
+
resize: 'vertical',
|
|
40
|
+
}),
|
|
41
|
+
)}
|
|
42
|
+
rows={4}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from './components/NavMenuLink'
|
|
|
16
16
|
export * from './components/Tab'
|
|
17
17
|
export * from './components/TabList'
|
|
18
18
|
export * from './components/TabPanel'
|
|
19
|
+
export * from './components/Tag'
|
|
20
|
+
export * from './components/Textarea'
|
|
19
21
|
export * from './components/Show'
|
|
20
22
|
|
|
21
23
|
// context
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/IconButton.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { iconButton } from '@cerberus/styled-system/recipes'\nimport type { ButtonProps } from './Button'\n\n/**\n * This module contains the Icon Button component.\n * @module\n */\n\nexport type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>\nexport interface IconButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n ariaLabel: string\n palette?: ButtonProps['palette']\n usage?: IconButtonUsage\n shape?: 'circle'\n}\n\n/**\n * A component that allows the user to perform actions using an icon\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/IconButton.tsx\n */\nexport function IconButton(props: IconButtonProps): JSX.Element {\n const { ariaLabel, palette, usage, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n aria-label={ariaLabel ?? 'Icon Button'}\n className={cx(\n nativeProps.className,\n iconButton({\n palette,\n usage,\n }),\n )}\n />\n )\n}\n"],"mappings":";AACA,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAwBvB;AAHG,SAAS,WAAW,OAAqC;AAC9D,QAAM,EAAE,WAAW,SAAS,OAAO,GAAG,YAAY,IAAI;AACtD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,cAAY,aAAa;AAAA,MACzB,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/IconButton.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { iconButton } from '@cerberus/styled-system/recipes'\nimport type { ButtonProps } from './Button'\n\n/**\n * This module contains the Icon Button component.\n * @module\n */\n\nexport type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>\nexport interface IconButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n ariaLabel: string\n palette?: ButtonProps['palette']\n usage?: IconButtonUsage\n shape?: 'circle'\n}\n\n/**\n * A component that allows the user to perform actions using an icon\n * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/IconButton.tsx\n */\nexport function IconButton(props: IconButtonProps): JSX.Element {\n const { ariaLabel, palette, usage, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n aria-label={ariaLabel ?? 'Icon Button'}\n className={cx(\n nativeProps.className,\n iconButton({\n palette,\n usage,\n }),\n )}\n />\n )\n}\n"],"mappings":";AACA,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAwBvB;AAHG,SAAS,WAAW,OAAqC;AAC9D,QAAM,EAAE,WAAW,SAAS,OAAO,GAAG,YAAY,IAAI;AACtD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,cAAY,aAAa;AAAA,MACzB,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|