@cerberus-design/react 0.1.3 → 0.2.0-next-df7f869
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 +69 -1
- package/build/legacy/chunk-LD5ZV46F.js +35 -0
- package/build/legacy/chunk-LD5ZV46F.js.map +1 -0
- package/build/legacy/chunk-OXVNTE4A.js +48 -0
- package/build/legacy/chunk-OXVNTE4A.js.map +1 -0
- package/build/legacy/{chunk-6YEAMVRY.js → chunk-X6PHIZRM.js} +4 -4
- package/build/legacy/chunk-YVUZSAJG.js +24 -0
- package/build/legacy/chunk-YVUZSAJG.js.map +1 -0
- package/build/{modern/chunk-KETL4ZJK.js → legacy/chunk-ZAU4JVLL.js} +3 -3
- package/build/{modern/chunk-KETL4ZJK.js.map → legacy/chunk-ZAU4JVLL.js.map} +1 -1
- package/build/legacy/components/FieldMessage.d.ts +2 -0
- package/build/legacy/components/FieldMessage.js +9 -0
- package/build/legacy/components/FieldMessage.js.map +1 -0
- package/build/legacy/components/Input.d.ts +2 -0
- package/build/legacy/components/Input.js +10 -0
- package/build/legacy/components/Input.js.map +1 -0
- package/build/legacy/components/Label.d.ts +2 -0
- package/build/legacy/components/Label.js +10 -0
- package/build/legacy/components/Label.js.map +1 -0
- package/build/legacy/components/NavMenuTrigger.js +2 -2
- package/build/legacy/context/field.js +1 -1
- package/build/legacy/index.d.ts +6 -0
- package/build/legacy/index.js +26 -14
- package/build/modern/_tsup-dts-rollup.d.ts +69 -1
- package/build/modern/chunk-LD5ZV46F.js +35 -0
- package/build/modern/chunk-LD5ZV46F.js.map +1 -0
- package/build/modern/chunk-OXVNTE4A.js +48 -0
- package/build/modern/chunk-OXVNTE4A.js.map +1 -0
- package/build/modern/{chunk-6YEAMVRY.js → chunk-X6PHIZRM.js} +4 -4
- package/build/modern/chunk-YVUZSAJG.js +24 -0
- package/build/modern/chunk-YVUZSAJG.js.map +1 -0
- package/build/{legacy/chunk-KETL4ZJK.js → modern/chunk-ZAU4JVLL.js} +3 -3
- package/build/{legacy/chunk-KETL4ZJK.js.map → modern/chunk-ZAU4JVLL.js.map} +1 -1
- package/build/modern/components/FieldMessage.d.ts +2 -0
- package/build/modern/components/FieldMessage.js +9 -0
- package/build/modern/components/FieldMessage.js.map +1 -0
- package/build/modern/components/Input.d.ts +2 -0
- package/build/modern/components/Input.js +10 -0
- package/build/modern/components/Input.js.map +1 -0
- package/build/modern/components/Label.d.ts +2 -0
- package/build/modern/components/Label.js +10 -0
- package/build/modern/components/Label.js.map +1 -0
- package/build/modern/components/NavMenuTrigger.js +2 -2
- package/build/modern/context/field.js +1 -1
- package/build/modern/index.d.ts +6 -0
- package/build/modern/index.js +26 -14
- package/package.json +2 -1
- package/src/components/FieldMessage.tsx +41 -0
- package/src/components/Input.tsx +36 -0
- package/src/components/Label.tsx +60 -0
- package/src/context/field.tsx +3 -3
- package/src/index.ts +3 -0
- /package/build/legacy/{chunk-6YEAMVRY.js.map → chunk-X6PHIZRM.js.map} +0 -0
- /package/build/modern/{chunk-6YEAMVRY.js.map → chunk-X6PHIZRM.js.map} +0 -0
|
@@ -2,6 +2,8 @@ import type { AnchorHTMLAttributes } from 'react';
|
|
|
2
2
|
import { ButtonHTMLAttributes } from 'react';
|
|
3
3
|
import { ElementType } from 'react';
|
|
4
4
|
import { HTMLAttributes } from 'react';
|
|
5
|
+
import type { InputHTMLAttributes } from 'react';
|
|
6
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
5
7
|
import { PropsWithChildren } from 'react';
|
|
6
8
|
import { ReactNode } from 'react';
|
|
7
9
|
import { RefObject } from 'react';
|
|
@@ -48,13 +50,41 @@ export { Field as Field_alias_1 }
|
|
|
48
50
|
|
|
49
51
|
declare interface FieldContextValue {
|
|
50
52
|
disabled?: boolean;
|
|
51
|
-
|
|
53
|
+
readOnly?: boolean;
|
|
52
54
|
required?: boolean;
|
|
53
55
|
invalid?: boolean;
|
|
54
56
|
}
|
|
55
57
|
export { FieldContextValue }
|
|
56
58
|
export { FieldContextValue as FieldContextValue_alias_1 }
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* A component that provides feedback about the field.
|
|
62
|
+
* @description [FieldMessage Docs](https://cerberus.digitalu.design/react/field-message)
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* <Field>
|
|
66
|
+
* <Label htmlFor="first_name">First Name</Label>
|
|
67
|
+
* <Input aria-describedBy="help:first_name" id="first_name" type="text" />
|
|
68
|
+
* <FieldMessage id="help:first_name">
|
|
69
|
+
* This will only be used in your account information.
|
|
70
|
+
* </FieldMessage>
|
|
71
|
+
* </Field>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function FieldMessage(props: FieldMessageProps): JSX_2.Element;
|
|
75
|
+
export { FieldMessage }
|
|
76
|
+
export { FieldMessage as FieldMessage_alias_1 }
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This module contains the FieldMessage component.
|
|
80
|
+
* @module
|
|
81
|
+
*/
|
|
82
|
+
declare interface FieldMessageProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
83
|
+
id: string;
|
|
84
|
+
}
|
|
85
|
+
export { FieldMessageProps }
|
|
86
|
+
export { FieldMessageProps as FieldMessageProps_alias_1 }
|
|
87
|
+
|
|
58
88
|
declare function getPosition(position: Positions): GetPositionResult;
|
|
59
89
|
export { getPosition }
|
|
60
90
|
export { getPosition as getPosition_alias_1 }
|
|
@@ -91,6 +121,44 @@ declare type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>;
|
|
|
91
121
|
export { IconButtonUsage }
|
|
92
122
|
export { IconButtonUsage as IconButtonUsage_alias_1 }
|
|
93
123
|
|
|
124
|
+
declare function Input(props: InputProps): JSX_2.Element;
|
|
125
|
+
export { Input }
|
|
126
|
+
export { Input as Input_alias_1 }
|
|
127
|
+
|
|
128
|
+
declare interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {
|
|
129
|
+
describedBy?: string;
|
|
130
|
+
id: string;
|
|
131
|
+
size?: 'sm' | 'md' | 'lg';
|
|
132
|
+
}
|
|
133
|
+
export { InputProps }
|
|
134
|
+
export { InputProps as InputProps_alias_1 }
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A screen ready friendly label component.
|
|
138
|
+
* @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
|
|
139
|
+
* @definition [Label docs](https://cerberus.digitalu.design/react/label)
|
|
140
|
+
* @example
|
|
141
|
+
* ```tsx
|
|
142
|
+
* <Field required>
|
|
143
|
+
* <Label htmlFor="test">Test Label</Label>
|
|
144
|
+
* </Field>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function Label(props: PropsWithChildren<LabelProps>): JSX_2.Element;
|
|
148
|
+
export { Label }
|
|
149
|
+
export { Label as Label_alias_1 }
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* This module contains the Label component.
|
|
153
|
+
* @module
|
|
154
|
+
*/
|
|
155
|
+
declare interface LabelProps extends HTMLAttributes<HTMLLabelElement> {
|
|
156
|
+
htmlFor: string;
|
|
157
|
+
hidden?: boolean;
|
|
158
|
+
}
|
|
159
|
+
export { LabelProps }
|
|
160
|
+
export { LabelProps as LabelProps_alias_1 }
|
|
161
|
+
|
|
94
162
|
declare const MODE_KEY = "cerberus-mode";
|
|
95
163
|
export { MODE_KEY }
|
|
96
164
|
export { MODE_KEY as MODE_KEY_alias_1 }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Show
|
|
3
|
+
} from "./chunk-R4H3352X.js";
|
|
4
|
+
import {
|
|
5
|
+
useFieldContext
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
|
+
|
|
8
|
+
// src/components/Input.tsx
|
|
9
|
+
import { WarningFilled } from "@cerberus/icons";
|
|
10
|
+
import { input } from "@cerberus/styled-system/recipes";
|
|
11
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
function Input(props) {
|
|
14
|
+
const { describedBy, size, ...nativeProps } = props;
|
|
15
|
+
const inputStyles = input({ size });
|
|
16
|
+
const { invalid, ...fieldStates } = useFieldContext();
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: inputStyles.root, children: [
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
"input",
|
|
20
|
+
{
|
|
21
|
+
...nativeProps,
|
|
22
|
+
...fieldStates,
|
|
23
|
+
...describedBy && { "aria-describedby": describedBy },
|
|
24
|
+
...invalid && { "aria-invalid": true },
|
|
25
|
+
className: cx("peer", nativeProps.className, inputStyles.input)
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ jsx(Show, { when: invalid, children: /* @__PURE__ */ jsx(WarningFilled, { className: inputStyles.icon }) })
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
Input
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-LD5ZV46F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes } from 'react'\nimport { WarningFilled } from '@cerberus/icons'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\nexport interface InputProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n size?: 'sm' | 'md' | 'lg'\n}\n\nexport function Input(props: InputProps) {\n const { describedBy, size, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n\n return (\n <div className={inputStyles.root}>\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n <Show when={invalid}>\n <WarningFilled className={inputStyles.icon} />\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,qBAAqB;AAC9B,SAAS,aAAa;AACtB,SAAS,UAAU;AAiBf,SACE,KADF;AANG,SAAS,MAAM,OAAmB;AACvC,QAAM,EAAE,aAAa,MAAM,GAAG,YAAY,IAAI;AAC9C,QAAM,cAAc,MAAM,EAAE,KAAK,CAAC;AAClC,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI,gBAAgB;AAEpD,SACE,qBAAC,SAAI,WAAW,YAAY,MAC1B;AAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,WAAW,GAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IACA,oBAAC,QAAK,MAAM,SACV,8BAAC,iBAAc,WAAW,YAAY,MAAM,GAC9C;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Show
|
|
3
|
+
} from "./chunk-R4H3352X.js";
|
|
4
|
+
import {
|
|
5
|
+
useFieldContext
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
|
+
|
|
8
|
+
// src/components/Label.tsx
|
|
9
|
+
import { label } from "@cerberus/styled-system/recipes";
|
|
10
|
+
import { css, cx } from "@cerberus/styled-system/css";
|
|
11
|
+
import { hstack } from "@cerberus/styled-system/patterns";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
function Label(props) {
|
|
14
|
+
const { hidden, ...nativeProps } = props;
|
|
15
|
+
const { required } = useFieldContext();
|
|
16
|
+
const usage = hidden ? "hidden" : "visible";
|
|
17
|
+
return /* @__PURE__ */ jsxs(
|
|
18
|
+
"label",
|
|
19
|
+
{
|
|
20
|
+
...nativeProps,
|
|
21
|
+
className: cx(
|
|
22
|
+
nativeProps.className,
|
|
23
|
+
label({ usage }),
|
|
24
|
+
hstack({
|
|
25
|
+
justify: "space-between"
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
children: [
|
|
29
|
+
props.children,
|
|
30
|
+
/* @__PURE__ */ jsx(Show, { when: required, children: /* @__PURE__ */ jsx(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
className: css({
|
|
34
|
+
color: "neutral.text.100",
|
|
35
|
+
fontSize: "inherit"
|
|
36
|
+
}),
|
|
37
|
+
children: "(required)"
|
|
38
|
+
}
|
|
39
|
+
) })
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
Label
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=chunk-OXVNTE4A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\nimport { hstack } from '@cerberus/styled-system/patterns'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport interface LabelProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, ...nativeProps } = props\n const { required } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n className={cx(\n nativeProps.className,\n label({ usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: 'neutral.text.100',\n fontSize: 'inherit',\n })}\n >\n (required)\n </span>\n </Show>\n </label>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,KAAK,UAAU;AAGxB,SAAS,cAAc;AA6BnB,SAYI,KAZJ;AANG,SAAS,MAAM,OAAsC;AAC1D,QAAM,EAAE,QAAQ,GAAG,YAAY,IAAI;AACnC,QAAM,EAAE,SAAS,IAAI,gBAAgB;AACrC,QAAM,QAAQ,SAAS,WAAW;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,MAAM,EAAE,MAAM,CAAC;AAAA,QACf,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,MAEC;AAAA,cAAM;AAAA,QACP,oBAAC,QAAK,MAAM,UACV;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,IAAI;AAAA,cACb,OAAO;AAAA,cACP,UAAU;AAAA,YACZ,CAAC;AAAA,YACF;AAAA;AAAA,QAED,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createNavTriggerProps
|
|
3
|
-
} from "./chunk-JF76VIL3.js";
|
|
4
1
|
import {
|
|
5
2
|
useNavMenuContext
|
|
6
3
|
} from "./chunk-KJUCHZHV.js";
|
|
4
|
+
import {
|
|
5
|
+
createNavTriggerProps
|
|
6
|
+
} from "./chunk-JF76VIL3.js";
|
|
7
7
|
import {
|
|
8
8
|
Show
|
|
9
9
|
} from "./chunk-R4H3352X.js";
|
|
@@ -79,4 +79,4 @@ function NavMenuTrigger(props) {
|
|
|
79
79
|
export {
|
|
80
80
|
NavMenuTrigger
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-X6PHIZRM.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFieldContext
|
|
3
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
4
|
+
|
|
5
|
+
// src/components/FieldMessage.tsx
|
|
6
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
7
|
+
import { fieldMessage } from "@cerberus/styled-system/recipes";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function FieldMessage(props) {
|
|
10
|
+
const { invalid } = useFieldContext();
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"small",
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
...invalid && { "aria-invalid": true },
|
|
16
|
+
className: cx(props.className, fieldMessage())
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
FieldMessage
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-YVUZSAJG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FieldMessage.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { fieldMessage } from '@cerberus/styled-system/recipes'\nimport { useFieldContext } from '../context/field'\n\n/**\n * This module contains the FieldMessage component.\n * @module\n */\n\nexport interface FieldMessageProps\n extends HTMLAttributes<HTMLParagraphElement> {\n id: string\n}\n\n/**\n * A component that provides feedback about the field.\n * @description [FieldMessage Docs](https://cerberus.digitalu.design/react/field-message)\n * @example\n * ```tsx\n * <Field>\n * <Label htmlFor=\"first_name\">First Name</Label>\n * <Input aria-describedBy=\"help:first_name\" id=\"first_name\" type=\"text\" />\n * <FieldMessage id=\"help:first_name\">\n * This will only be used in your account information.\n * </FieldMessage>\n * </Field>\n * ```\n */\nexport function FieldMessage(props: FieldMessageProps) {\n const { invalid } = useFieldContext()\n return (\n <small\n {...props}\n {...(invalid && { 'aria-invalid': true })}\n className={cx(props.className, fieldMessage())}\n />\n )\n}\n"],"mappings":";;;;;AAGA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AA8BzB;AAHG,SAAS,aAAa,OAA0B;AACrD,QAAM,EAAE,QAAQ,IAAI,gBAAgB;AACpC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,MACvC,WAAW,GAAG,MAAM,WAAW,aAAa,CAAC;AAAA;AAAA,EAC/C;AAEJ;","names":[]}
|
|
@@ -10,11 +10,11 @@ function Field(props) {
|
|
|
10
10
|
const value = useMemo(
|
|
11
11
|
() => ({
|
|
12
12
|
disabled: props.disabled,
|
|
13
|
-
|
|
13
|
+
readOnly: props.readOnly,
|
|
14
14
|
required: props.required,
|
|
15
15
|
invalid: props.invalid
|
|
16
16
|
}),
|
|
17
|
-
[props.disabled, props.
|
|
17
|
+
[props.disabled, props.readOnly, props.required, props.invalid]
|
|
18
18
|
);
|
|
19
19
|
return /* @__PURE__ */ jsx(FieldContext.Provider, { value, children: props.children });
|
|
20
20
|
}
|
|
@@ -30,4 +30,4 @@ export {
|
|
|
30
30
|
Field,
|
|
31
31
|
useFieldContext
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-ZAU4JVLL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/field.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\nexport interface FieldContextValue {\n disabled?: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../src/context/field.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\nexport interface FieldContextValue {\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n invalid?: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\nexport function Field(\n props: PropsWithChildren<FieldContextValue>,\n): JSX.Element {\n const value = useMemo(\n () => ({\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n invalid: props.invalid,\n }),\n [props.disabled, props.readOnly, props.required, props.invalid],\n )\n\n return (\n <FieldContext.Provider value={value}>\n {props.children}\n </FieldContext.Provider>\n )\n}\n\nexport function useFieldContext(): FieldContextValue {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useFieldContext must be used within a Field Provider.')\n }\n return context\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAyBH;AAhBJ,IAAM,eAAe,cAAwC,IAAI;AAE1D,SAAS,MACd,OACa;AACb,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,CAAC,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,OAAO;AAAA,EAChE;AAEA,SACE,oBAAC,aAAa,UAAb,EAAsB,OACpB,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
NavMenuTrigger
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-JF76VIL3.js";
|
|
4
|
+
} from "../chunk-X6PHIZRM.js";
|
|
6
5
|
import "../chunk-KJUCHZHV.js";
|
|
6
|
+
import "../chunk-JF76VIL3.js";
|
|
7
7
|
import "../chunk-R4H3352X.js";
|
|
8
8
|
export {
|
|
9
9
|
NavMenuTrigger
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export { Button } from './_tsup-dts-rollup';
|
|
2
2
|
export { ButtonProps } from './_tsup-dts-rollup';
|
|
3
|
+
export { FieldMessage } from './_tsup-dts-rollup';
|
|
4
|
+
export { FieldMessageProps } from './_tsup-dts-rollup';
|
|
3
5
|
export { IconButton } from './_tsup-dts-rollup';
|
|
4
6
|
export { IconButtonUsage } from './_tsup-dts-rollup';
|
|
5
7
|
export { IconButtonProps } from './_tsup-dts-rollup';
|
|
8
|
+
export { Input } from './_tsup-dts-rollup';
|
|
9
|
+
export { InputProps } from './_tsup-dts-rollup';
|
|
10
|
+
export { Label } from './_tsup-dts-rollup';
|
|
11
|
+
export { LabelProps } from './_tsup-dts-rollup';
|
|
6
12
|
export { NavMenuTrigger } from './_tsup-dts-rollup';
|
|
7
13
|
export { NavMenuTriggerProps } from './_tsup-dts-rollup';
|
|
8
14
|
export { getPosition } from './_tsup-dts-rollup';
|
package/build/legacy/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Label
|
|
3
|
+
} from "./chunk-OXVNTE4A.js";
|
|
4
|
+
import {
|
|
5
|
+
NavMenuLink
|
|
6
|
+
} from "./chunk-JA4IX7GN.js";
|
|
7
|
+
import {
|
|
8
|
+
NavMenuList,
|
|
9
|
+
getPosition
|
|
10
|
+
} from "./chunk-WSQTX34C.js";
|
|
1
11
|
import {
|
|
2
12
|
NavMenuTrigger
|
|
3
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-X6PHIZRM.js";
|
|
4
14
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
15
|
+
NavMenu,
|
|
16
|
+
useNavMenuContext
|
|
17
|
+
} from "./chunk-KJUCHZHV.js";
|
|
8
18
|
import "./chunk-55J6XMHW.js";
|
|
9
19
|
import {
|
|
10
20
|
createNavTriggerProps
|
|
@@ -19,27 +29,29 @@ import {
|
|
|
19
29
|
import {
|
|
20
30
|
Button
|
|
21
31
|
} from "./chunk-XFWARXLU.js";
|
|
32
|
+
import {
|
|
33
|
+
FieldMessage
|
|
34
|
+
} from "./chunk-YVUZSAJG.js";
|
|
22
35
|
import {
|
|
23
36
|
IconButton
|
|
24
37
|
} from "./chunk-BPIYUAYS.js";
|
|
25
38
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
NavMenuList,
|
|
30
|
-
getPosition
|
|
31
|
-
} from "./chunk-WSQTX34C.js";
|
|
32
|
-
import {
|
|
33
|
-
NavMenu,
|
|
34
|
-
useNavMenuContext
|
|
35
|
-
} from "./chunk-KJUCHZHV.js";
|
|
39
|
+
Input
|
|
40
|
+
} from "./chunk-LD5ZV46F.js";
|
|
36
41
|
import {
|
|
37
42
|
Show
|
|
38
43
|
} from "./chunk-R4H3352X.js";
|
|
44
|
+
import {
|
|
45
|
+
Field,
|
|
46
|
+
useFieldContext
|
|
47
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
39
48
|
export {
|
|
40
49
|
Button,
|
|
41
50
|
Field,
|
|
51
|
+
FieldMessage,
|
|
42
52
|
IconButton,
|
|
53
|
+
Input,
|
|
54
|
+
Label,
|
|
43
55
|
MODE_KEY,
|
|
44
56
|
NavMenu,
|
|
45
57
|
NavMenuLink,
|
|
@@ -2,6 +2,8 @@ import type { AnchorHTMLAttributes } from 'react';
|
|
|
2
2
|
import { ButtonHTMLAttributes } from 'react';
|
|
3
3
|
import { ElementType } from 'react';
|
|
4
4
|
import { HTMLAttributes } from 'react';
|
|
5
|
+
import type { InputHTMLAttributes } from 'react';
|
|
6
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
5
7
|
import { PropsWithChildren } from 'react';
|
|
6
8
|
import { ReactNode } from 'react';
|
|
7
9
|
import { RefObject } from 'react';
|
|
@@ -48,13 +50,41 @@ export { Field as Field_alias_1 }
|
|
|
48
50
|
|
|
49
51
|
declare interface FieldContextValue {
|
|
50
52
|
disabled?: boolean;
|
|
51
|
-
|
|
53
|
+
readOnly?: boolean;
|
|
52
54
|
required?: boolean;
|
|
53
55
|
invalid?: boolean;
|
|
54
56
|
}
|
|
55
57
|
export { FieldContextValue }
|
|
56
58
|
export { FieldContextValue as FieldContextValue_alias_1 }
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* A component that provides feedback about the field.
|
|
62
|
+
* @description [FieldMessage Docs](https://cerberus.digitalu.design/react/field-message)
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* <Field>
|
|
66
|
+
* <Label htmlFor="first_name">First Name</Label>
|
|
67
|
+
* <Input aria-describedBy="help:first_name" id="first_name" type="text" />
|
|
68
|
+
* <FieldMessage id="help:first_name">
|
|
69
|
+
* This will only be used in your account information.
|
|
70
|
+
* </FieldMessage>
|
|
71
|
+
* </Field>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function FieldMessage(props: FieldMessageProps): JSX_2.Element;
|
|
75
|
+
export { FieldMessage }
|
|
76
|
+
export { FieldMessage as FieldMessage_alias_1 }
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This module contains the FieldMessage component.
|
|
80
|
+
* @module
|
|
81
|
+
*/
|
|
82
|
+
declare interface FieldMessageProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
83
|
+
id: string;
|
|
84
|
+
}
|
|
85
|
+
export { FieldMessageProps }
|
|
86
|
+
export { FieldMessageProps as FieldMessageProps_alias_1 }
|
|
87
|
+
|
|
58
88
|
declare function getPosition(position: Positions): GetPositionResult;
|
|
59
89
|
export { getPosition }
|
|
60
90
|
export { getPosition as getPosition_alias_1 }
|
|
@@ -91,6 +121,44 @@ declare type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>;
|
|
|
91
121
|
export { IconButtonUsage }
|
|
92
122
|
export { IconButtonUsage as IconButtonUsage_alias_1 }
|
|
93
123
|
|
|
124
|
+
declare function Input(props: InputProps): JSX_2.Element;
|
|
125
|
+
export { Input }
|
|
126
|
+
export { Input as Input_alias_1 }
|
|
127
|
+
|
|
128
|
+
declare interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {
|
|
129
|
+
describedBy?: string;
|
|
130
|
+
id: string;
|
|
131
|
+
size?: 'sm' | 'md' | 'lg';
|
|
132
|
+
}
|
|
133
|
+
export { InputProps }
|
|
134
|
+
export { InputProps as InputProps_alias_1 }
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A screen ready friendly label component.
|
|
138
|
+
* @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
|
|
139
|
+
* @definition [Label docs](https://cerberus.digitalu.design/react/label)
|
|
140
|
+
* @example
|
|
141
|
+
* ```tsx
|
|
142
|
+
* <Field required>
|
|
143
|
+
* <Label htmlFor="test">Test Label</Label>
|
|
144
|
+
* </Field>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function Label(props: PropsWithChildren<LabelProps>): JSX_2.Element;
|
|
148
|
+
export { Label }
|
|
149
|
+
export { Label as Label_alias_1 }
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* This module contains the Label component.
|
|
153
|
+
* @module
|
|
154
|
+
*/
|
|
155
|
+
declare interface LabelProps extends HTMLAttributes<HTMLLabelElement> {
|
|
156
|
+
htmlFor: string;
|
|
157
|
+
hidden?: boolean;
|
|
158
|
+
}
|
|
159
|
+
export { LabelProps }
|
|
160
|
+
export { LabelProps as LabelProps_alias_1 }
|
|
161
|
+
|
|
94
162
|
declare const MODE_KEY = "cerberus-mode";
|
|
95
163
|
export { MODE_KEY }
|
|
96
164
|
export { MODE_KEY as MODE_KEY_alias_1 }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Show
|
|
3
|
+
} from "./chunk-R4H3352X.js";
|
|
4
|
+
import {
|
|
5
|
+
useFieldContext
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
|
+
|
|
8
|
+
// src/components/Input.tsx
|
|
9
|
+
import { WarningFilled } from "@cerberus/icons";
|
|
10
|
+
import { input } from "@cerberus/styled-system/recipes";
|
|
11
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
function Input(props) {
|
|
14
|
+
const { describedBy, size, ...nativeProps } = props;
|
|
15
|
+
const inputStyles = input({ size });
|
|
16
|
+
const { invalid, ...fieldStates } = useFieldContext();
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: inputStyles.root, children: [
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
"input",
|
|
20
|
+
{
|
|
21
|
+
...nativeProps,
|
|
22
|
+
...fieldStates,
|
|
23
|
+
...describedBy && { "aria-describedby": describedBy },
|
|
24
|
+
...invalid && { "aria-invalid": true },
|
|
25
|
+
className: cx("peer", nativeProps.className, inputStyles.input)
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ jsx(Show, { when: invalid, children: /* @__PURE__ */ jsx(WarningFilled, { className: inputStyles.icon }) })
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
Input
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-LD5ZV46F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes } from 'react'\nimport { WarningFilled } from '@cerberus/icons'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\nexport interface InputProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n size?: 'sm' | 'md' | 'lg'\n}\n\nexport function Input(props: InputProps) {\n const { describedBy, size, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n\n return (\n <div className={inputStyles.root}>\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n <Show when={invalid}>\n <WarningFilled className={inputStyles.icon} />\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,qBAAqB;AAC9B,SAAS,aAAa;AACtB,SAAS,UAAU;AAiBf,SACE,KADF;AANG,SAAS,MAAM,OAAmB;AACvC,QAAM,EAAE,aAAa,MAAM,GAAG,YAAY,IAAI;AAC9C,QAAM,cAAc,MAAM,EAAE,KAAK,CAAC;AAClC,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI,gBAAgB;AAEpD,SACE,qBAAC,SAAI,WAAW,YAAY,MAC1B;AAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,WAAW,GAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IACA,oBAAC,QAAK,MAAM,SACV,8BAAC,iBAAc,WAAW,YAAY,MAAM,GAC9C;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Show
|
|
3
|
+
} from "./chunk-R4H3352X.js";
|
|
4
|
+
import {
|
|
5
|
+
useFieldContext
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
|
+
|
|
8
|
+
// src/components/Label.tsx
|
|
9
|
+
import { label } from "@cerberus/styled-system/recipes";
|
|
10
|
+
import { css, cx } from "@cerberus/styled-system/css";
|
|
11
|
+
import { hstack } from "@cerberus/styled-system/patterns";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
function Label(props) {
|
|
14
|
+
const { hidden, ...nativeProps } = props;
|
|
15
|
+
const { required } = useFieldContext();
|
|
16
|
+
const usage = hidden ? "hidden" : "visible";
|
|
17
|
+
return /* @__PURE__ */ jsxs(
|
|
18
|
+
"label",
|
|
19
|
+
{
|
|
20
|
+
...nativeProps,
|
|
21
|
+
className: cx(
|
|
22
|
+
nativeProps.className,
|
|
23
|
+
label({ usage }),
|
|
24
|
+
hstack({
|
|
25
|
+
justify: "space-between"
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
children: [
|
|
29
|
+
props.children,
|
|
30
|
+
/* @__PURE__ */ jsx(Show, { when: required, children: /* @__PURE__ */ jsx(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
className: css({
|
|
34
|
+
color: "neutral.text.100",
|
|
35
|
+
fontSize: "inherit"
|
|
36
|
+
}),
|
|
37
|
+
children: "(required)"
|
|
38
|
+
}
|
|
39
|
+
) })
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
Label
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=chunk-OXVNTE4A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\nimport { hstack } from '@cerberus/styled-system/patterns'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport interface LabelProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, ...nativeProps } = props\n const { required } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n className={cx(\n nativeProps.className,\n label({ usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: 'neutral.text.100',\n fontSize: 'inherit',\n })}\n >\n (required)\n </span>\n </Show>\n </label>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,KAAK,UAAU;AAGxB,SAAS,cAAc;AA6BnB,SAYI,KAZJ;AANG,SAAS,MAAM,OAAsC;AAC1D,QAAM,EAAE,QAAQ,GAAG,YAAY,IAAI;AACnC,QAAM,EAAE,SAAS,IAAI,gBAAgB;AACrC,QAAM,QAAQ,SAAS,WAAW;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,MAAM,EAAE,MAAM,CAAC;AAAA,QACf,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,MAEC;AAAA,cAAM;AAAA,QACP,oBAAC,QAAK,MAAM,UACV;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,IAAI;AAAA,cACb,OAAO;AAAA,cACP,UAAU;AAAA,YACZ,CAAC;AAAA,YACF;AAAA;AAAA,QAED,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createNavTriggerProps
|
|
3
|
-
} from "./chunk-JF76VIL3.js";
|
|
4
1
|
import {
|
|
5
2
|
useNavMenuContext
|
|
6
3
|
} from "./chunk-KJUCHZHV.js";
|
|
4
|
+
import {
|
|
5
|
+
createNavTriggerProps
|
|
6
|
+
} from "./chunk-JF76VIL3.js";
|
|
7
7
|
import {
|
|
8
8
|
Show
|
|
9
9
|
} from "./chunk-R4H3352X.js";
|
|
@@ -79,4 +79,4 @@ function NavMenuTrigger(props) {
|
|
|
79
79
|
export {
|
|
80
80
|
NavMenuTrigger
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-X6PHIZRM.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFieldContext
|
|
3
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
4
|
+
|
|
5
|
+
// src/components/FieldMessage.tsx
|
|
6
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
7
|
+
import { fieldMessage } from "@cerberus/styled-system/recipes";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function FieldMessage(props) {
|
|
10
|
+
const { invalid } = useFieldContext();
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"small",
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
...invalid && { "aria-invalid": true },
|
|
16
|
+
className: cx(props.className, fieldMessage())
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
FieldMessage
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-YVUZSAJG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FieldMessage.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { fieldMessage } from '@cerberus/styled-system/recipes'\nimport { useFieldContext } from '../context/field'\n\n/**\n * This module contains the FieldMessage component.\n * @module\n */\n\nexport interface FieldMessageProps\n extends HTMLAttributes<HTMLParagraphElement> {\n id: string\n}\n\n/**\n * A component that provides feedback about the field.\n * @description [FieldMessage Docs](https://cerberus.digitalu.design/react/field-message)\n * @example\n * ```tsx\n * <Field>\n * <Label htmlFor=\"first_name\">First Name</Label>\n * <Input aria-describedBy=\"help:first_name\" id=\"first_name\" type=\"text\" />\n * <FieldMessage id=\"help:first_name\">\n * This will only be used in your account information.\n * </FieldMessage>\n * </Field>\n * ```\n */\nexport function FieldMessage(props: FieldMessageProps) {\n const { invalid } = useFieldContext()\n return (\n <small\n {...props}\n {...(invalid && { 'aria-invalid': true })}\n className={cx(props.className, fieldMessage())}\n />\n )\n}\n"],"mappings":";;;;;AAGA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AA8BzB;AAHG,SAAS,aAAa,OAA0B;AACrD,QAAM,EAAE,QAAQ,IAAI,gBAAgB;AACpC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,MACvC,WAAW,GAAG,MAAM,WAAW,aAAa,CAAC;AAAA;AAAA,EAC/C;AAEJ;","names":[]}
|
|
@@ -10,11 +10,11 @@ function Field(props) {
|
|
|
10
10
|
const value = useMemo(
|
|
11
11
|
() => ({
|
|
12
12
|
disabled: props.disabled,
|
|
13
|
-
|
|
13
|
+
readOnly: props.readOnly,
|
|
14
14
|
required: props.required,
|
|
15
15
|
invalid: props.invalid
|
|
16
16
|
}),
|
|
17
|
-
[props.disabled, props.
|
|
17
|
+
[props.disabled, props.readOnly, props.required, props.invalid]
|
|
18
18
|
);
|
|
19
19
|
return /* @__PURE__ */ jsx(FieldContext.Provider, { value, children: props.children });
|
|
20
20
|
}
|
|
@@ -30,4 +30,4 @@ export {
|
|
|
30
30
|
Field,
|
|
31
31
|
useFieldContext
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-ZAU4JVLL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/field.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\nexport interface FieldContextValue {\n disabled?: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../src/context/field.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\nexport interface FieldContextValue {\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n invalid?: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\nexport function Field(\n props: PropsWithChildren<FieldContextValue>,\n): JSX.Element {\n const value = useMemo(\n () => ({\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n invalid: props.invalid,\n }),\n [props.disabled, props.readOnly, props.required, props.invalid],\n )\n\n return (\n <FieldContext.Provider value={value}>\n {props.children}\n </FieldContext.Provider>\n )\n}\n\nexport function useFieldContext(): FieldContextValue {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useFieldContext must be used within a Field Provider.')\n }\n return context\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAyBH;AAhBJ,IAAM,eAAe,cAAwC,IAAI;AAE1D,SAAS,MACd,OACa;AACb,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,CAAC,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,OAAO;AAAA,EAChE;AAEA,SACE,oBAAC,aAAa,UAAb,EAAsB,OACpB,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
NavMenuTrigger
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-JF76VIL3.js";
|
|
4
|
+
} from "../chunk-X6PHIZRM.js";
|
|
6
5
|
import "../chunk-KJUCHZHV.js";
|
|
6
|
+
import "../chunk-JF76VIL3.js";
|
|
7
7
|
import "../chunk-R4H3352X.js";
|
|
8
8
|
export {
|
|
9
9
|
NavMenuTrigger
|
package/build/modern/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export { Button } from './_tsup-dts-rollup';
|
|
2
2
|
export { ButtonProps } from './_tsup-dts-rollup';
|
|
3
|
+
export { FieldMessage } from './_tsup-dts-rollup';
|
|
4
|
+
export { FieldMessageProps } from './_tsup-dts-rollup';
|
|
3
5
|
export { IconButton } from './_tsup-dts-rollup';
|
|
4
6
|
export { IconButtonUsage } from './_tsup-dts-rollup';
|
|
5
7
|
export { IconButtonProps } from './_tsup-dts-rollup';
|
|
8
|
+
export { Input } from './_tsup-dts-rollup';
|
|
9
|
+
export { InputProps } from './_tsup-dts-rollup';
|
|
10
|
+
export { Label } from './_tsup-dts-rollup';
|
|
11
|
+
export { LabelProps } from './_tsup-dts-rollup';
|
|
6
12
|
export { NavMenuTrigger } from './_tsup-dts-rollup';
|
|
7
13
|
export { NavMenuTriggerProps } from './_tsup-dts-rollup';
|
|
8
14
|
export { getPosition } from './_tsup-dts-rollup';
|
package/build/modern/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Label
|
|
3
|
+
} from "./chunk-OXVNTE4A.js";
|
|
4
|
+
import {
|
|
5
|
+
NavMenuLink
|
|
6
|
+
} from "./chunk-JA4IX7GN.js";
|
|
7
|
+
import {
|
|
8
|
+
NavMenuList,
|
|
9
|
+
getPosition
|
|
10
|
+
} from "./chunk-WSQTX34C.js";
|
|
1
11
|
import {
|
|
2
12
|
NavMenuTrigger
|
|
3
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-X6PHIZRM.js";
|
|
4
14
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
15
|
+
NavMenu,
|
|
16
|
+
useNavMenuContext
|
|
17
|
+
} from "./chunk-KJUCHZHV.js";
|
|
8
18
|
import "./chunk-55J6XMHW.js";
|
|
9
19
|
import {
|
|
10
20
|
createNavTriggerProps
|
|
@@ -19,27 +29,29 @@ import {
|
|
|
19
29
|
import {
|
|
20
30
|
Button
|
|
21
31
|
} from "./chunk-XFWARXLU.js";
|
|
32
|
+
import {
|
|
33
|
+
FieldMessage
|
|
34
|
+
} from "./chunk-YVUZSAJG.js";
|
|
22
35
|
import {
|
|
23
36
|
IconButton
|
|
24
37
|
} from "./chunk-BPIYUAYS.js";
|
|
25
38
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
NavMenuList,
|
|
30
|
-
getPosition
|
|
31
|
-
} from "./chunk-WSQTX34C.js";
|
|
32
|
-
import {
|
|
33
|
-
NavMenu,
|
|
34
|
-
useNavMenuContext
|
|
35
|
-
} from "./chunk-KJUCHZHV.js";
|
|
39
|
+
Input
|
|
40
|
+
} from "./chunk-LD5ZV46F.js";
|
|
36
41
|
import {
|
|
37
42
|
Show
|
|
38
43
|
} from "./chunk-R4H3352X.js";
|
|
44
|
+
import {
|
|
45
|
+
Field,
|
|
46
|
+
useFieldContext
|
|
47
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
39
48
|
export {
|
|
40
49
|
Button,
|
|
41
50
|
Field,
|
|
51
|
+
FieldMessage,
|
|
42
52
|
IconButton,
|
|
53
|
+
Input,
|
|
54
|
+
Label,
|
|
43
55
|
MODE_KEY,
|
|
44
56
|
NavMenu,
|
|
45
57
|
NavMenuLink,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-next-df7f869",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@cerberus/panda-preset": "npm:@jsr/cerberus__panda-preset",
|
|
12
12
|
"@cerberus/styled-system": "npm:@cerberus-design/styled-system@next",
|
|
13
|
+
"@cerberus/icons": "npm:@jsr/cerberus__icons",
|
|
13
14
|
"@pandacss/dev": "*",
|
|
14
15
|
"react": "*",
|
|
15
16
|
"react-dom": "*"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react'
|
|
4
|
+
import { cx } from '@cerberus/styled-system/css'
|
|
5
|
+
import { fieldMessage } from '@cerberus/styled-system/recipes'
|
|
6
|
+
import { useFieldContext } from '../context/field'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This module contains the FieldMessage component.
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface FieldMessageProps
|
|
14
|
+
extends HTMLAttributes<HTMLParagraphElement> {
|
|
15
|
+
id: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A component that provides feedback about the field.
|
|
20
|
+
* @description [FieldMessage Docs](https://cerberus.digitalu.design/react/field-message)
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Field>
|
|
24
|
+
* <Label htmlFor="first_name">First Name</Label>
|
|
25
|
+
* <Input aria-describedBy="help:first_name" id="first_name" type="text" />
|
|
26
|
+
* <FieldMessage id="help:first_name">
|
|
27
|
+
* This will only be used in your account information.
|
|
28
|
+
* </FieldMessage>
|
|
29
|
+
* </Field>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function FieldMessage(props: FieldMessageProps) {
|
|
33
|
+
const { invalid } = useFieldContext()
|
|
34
|
+
return (
|
|
35
|
+
<small
|
|
36
|
+
{...props}
|
|
37
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
38
|
+
className={cx(props.className, fieldMessage())}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { InputHTMLAttributes } from 'react'
|
|
4
|
+
import { WarningFilled } from '@cerberus/icons'
|
|
5
|
+
import { input } from '@cerberus/styled-system/recipes'
|
|
6
|
+
import { cx } from '@cerberus/styled-system/css'
|
|
7
|
+
import { useFieldContext } from '../context/field'
|
|
8
|
+
import { Show } from './Show'
|
|
9
|
+
|
|
10
|
+
export interface InputProps
|
|
11
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {
|
|
12
|
+
describedBy?: string
|
|
13
|
+
id: string
|
|
14
|
+
size?: 'sm' | 'md' | 'lg'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function Input(props: InputProps) {
|
|
18
|
+
const { describedBy, size, ...nativeProps } = props
|
|
19
|
+
const inputStyles = input({ size })
|
|
20
|
+
const { invalid, ...fieldStates } = useFieldContext()
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className={inputStyles.root}>
|
|
24
|
+
<input
|
|
25
|
+
{...nativeProps}
|
|
26
|
+
{...fieldStates}
|
|
27
|
+
{...(describedBy && { 'aria-describedby': describedBy })}
|
|
28
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
29
|
+
className={cx('peer', nativeProps.className, inputStyles.input)}
|
|
30
|
+
/>
|
|
31
|
+
<Show when={invalid}>
|
|
32
|
+
<WarningFilled className={inputStyles.icon} />
|
|
33
|
+
</Show>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes, PropsWithChildren } from 'react'
|
|
4
|
+
import { label } from '@cerberus/styled-system/recipes'
|
|
5
|
+
import { css, cx } from '@cerberus/styled-system/css'
|
|
6
|
+
import { useFieldContext } from '../context/field'
|
|
7
|
+
import { Show } from './Show'
|
|
8
|
+
import { hstack } from '@cerberus/styled-system/patterns'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This module contains the Label component.
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface LabelProps extends HTMLAttributes<HTMLLabelElement> {
|
|
16
|
+
htmlFor: string
|
|
17
|
+
hidden?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A screen ready friendly label component.
|
|
22
|
+
* @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
|
|
23
|
+
* @definition [Label docs](https://cerberus.digitalu.design/react/label)
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Field required>
|
|
27
|
+
* <Label htmlFor="test">Test Label</Label>
|
|
28
|
+
* </Field>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function Label(props: PropsWithChildren<LabelProps>) {
|
|
32
|
+
const { hidden, ...nativeProps } = props
|
|
33
|
+
const { required } = useFieldContext()
|
|
34
|
+
const usage = hidden ? 'hidden' : 'visible'
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<label
|
|
38
|
+
{...nativeProps}
|
|
39
|
+
className={cx(
|
|
40
|
+
nativeProps.className,
|
|
41
|
+
label({ usage }),
|
|
42
|
+
hstack({
|
|
43
|
+
justify: 'space-between',
|
|
44
|
+
}),
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
{props.children}
|
|
48
|
+
<Show when={required}>
|
|
49
|
+
<span
|
|
50
|
+
className={css({
|
|
51
|
+
color: 'neutral.text.100',
|
|
52
|
+
fontSize: 'inherit',
|
|
53
|
+
})}
|
|
54
|
+
>
|
|
55
|
+
(required)
|
|
56
|
+
</span>
|
|
57
|
+
</Show>
|
|
58
|
+
</label>
|
|
59
|
+
)
|
|
60
|
+
}
|
package/src/context/field.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export interface FieldContextValue {
|
|
11
11
|
disabled?: boolean
|
|
12
|
-
|
|
12
|
+
readOnly?: boolean
|
|
13
13
|
required?: boolean
|
|
14
14
|
invalid?: boolean
|
|
15
15
|
}
|
|
@@ -22,11 +22,11 @@ export function Field(
|
|
|
22
22
|
const value = useMemo(
|
|
23
23
|
() => ({
|
|
24
24
|
disabled: props.disabled,
|
|
25
|
-
|
|
25
|
+
readOnly: props.readOnly,
|
|
26
26
|
required: props.required,
|
|
27
27
|
invalid: props.invalid,
|
|
28
28
|
}),
|
|
29
|
-
[props.disabled, props.
|
|
29
|
+
[props.disabled, props.readOnly, props.required, props.invalid],
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
return (
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
// components
|
|
7
7
|
|
|
8
8
|
export * from './components/Button'
|
|
9
|
+
export * from './components/FieldMessage'
|
|
9
10
|
export * from './components/IconButton'
|
|
11
|
+
export * from './components/Input'
|
|
12
|
+
export * from './components/Label'
|
|
10
13
|
export * from './components/NavMenuTrigger'
|
|
11
14
|
export * from './components/NavMenuList'
|
|
12
15
|
export * from './components/NavMenuLink'
|
|
File without changes
|
|
File without changes
|