@cerberus-design/react 0.1.3-next-9be4883 → 0.1.3-next-59f45d9
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 +14 -1
- package/build/legacy/chunk-LD5ZV46F.js +35 -0
- package/build/legacy/chunk-LD5ZV46F.js.map +1 -0
- package/build/legacy/{chunk-46TCLT7U.js → chunk-OXVNTE4A.js} +4 -4
- package/build/{modern/chunk-46TCLT7U.js.map → legacy/chunk-OXVNTE4A.js.map} +1 -1
- package/build/{modern/chunk-6VY34K3P.js → legacy/chunk-YVUZSAJG.js} +2 -2
- package/build/legacy/{chunk-KETL4ZJK.js → chunk-ZAU4JVLL.js} +3 -3
- package/build/legacy/{chunk-KETL4ZJK.js.map → chunk-ZAU4JVLL.js.map} +1 -1
- package/build/legacy/components/FieldMessage.js +2 -2
- 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.js +2 -2
- package/build/legacy/context/field.js +1 -1
- package/build/legacy/index.d.ts +2 -0
- package/build/legacy/index.js +8 -4
- package/build/modern/_tsup-dts-rollup.d.ts +14 -1
- package/build/modern/chunk-LD5ZV46F.js +35 -0
- package/build/modern/chunk-LD5ZV46F.js.map +1 -0
- package/build/modern/{chunk-46TCLT7U.js → chunk-OXVNTE4A.js} +4 -4
- package/build/{legacy/chunk-46TCLT7U.js.map → modern/chunk-OXVNTE4A.js.map} +1 -1
- package/build/{legacy/chunk-6VY34K3P.js → modern/chunk-YVUZSAJG.js} +2 -2
- package/build/modern/{chunk-KETL4ZJK.js → chunk-ZAU4JVLL.js} +3 -3
- package/build/modern/{chunk-KETL4ZJK.js.map → chunk-ZAU4JVLL.js.map} +1 -1
- package/build/modern/components/FieldMessage.js +2 -2
- 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.js +2 -2
- package/build/modern/context/field.js +1 -1
- package/build/modern/index.d.ts +2 -0
- package/build/modern/index.js +8 -4
- package/package.json +2 -1
- package/src/components/Input.tsx +36 -0
- package/src/components/Label.tsx +2 -2
- package/src/context/field.tsx +3 -3
- package/src/index.ts +1 -0
- /package/build/legacy/{chunk-6VY34K3P.js.map → chunk-YVUZSAJG.js.map} +0 -0
- /package/build/modern/{chunk-6VY34K3P.js.map → chunk-YVUZSAJG.js.map} +0 -0
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
6
7
|
import { PropsWithChildren } from 'react';
|
|
7
8
|
import { ReactNode } from 'react';
|
|
@@ -49,7 +50,7 @@ export { Field as Field_alias_1 }
|
|
|
49
50
|
|
|
50
51
|
declare interface FieldContextValue {
|
|
51
52
|
disabled?: boolean;
|
|
52
|
-
|
|
53
|
+
readOnly?: boolean;
|
|
53
54
|
required?: boolean;
|
|
54
55
|
invalid?: boolean;
|
|
55
56
|
}
|
|
@@ -120,6 +121,18 @@ declare type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>;
|
|
|
120
121
|
export { IconButtonUsage }
|
|
121
122
|
export { IconButtonUsage as IconButtonUsage_alias_1 }
|
|
122
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
|
+
|
|
123
136
|
/**
|
|
124
137
|
* A screen ready friendly label component.
|
|
125
138
|
* @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
|
|
@@ -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":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-R4H3352X.js";
|
|
4
4
|
import {
|
|
5
5
|
useFieldContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
7
|
|
|
8
8
|
// src/components/Label.tsx
|
|
9
9
|
import { label } from "@cerberus/styled-system/recipes";
|
|
@@ -27,14 +27,14 @@ function Label(props) {
|
|
|
27
27
|
),
|
|
28
28
|
children: [
|
|
29
29
|
props.children,
|
|
30
|
-
/* @__PURE__ */ jsx(Show, { when:
|
|
30
|
+
/* @__PURE__ */ jsx(Show, { when: required, children: /* @__PURE__ */ jsx(
|
|
31
31
|
"span",
|
|
32
32
|
{
|
|
33
33
|
className: css({
|
|
34
34
|
color: "neutral.text.100",
|
|
35
35
|
fontSize: "inherit"
|
|
36
36
|
}),
|
|
37
|
-
children: "(
|
|
37
|
+
children: "(required)"
|
|
38
38
|
}
|
|
39
39
|
) })
|
|
40
40
|
]
|
|
@@ -45,4 +45,4 @@ function Label(props) {
|
|
|
45
45
|
export {
|
|
46
46
|
Label
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-OXVNTE4A.js.map
|
|
@@ -1 +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={
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useFieldContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
4
4
|
|
|
5
5
|
// src/components/FieldMessage.tsx
|
|
6
6
|
import { cx } from "@cerberus/styled-system/css";
|
|
@@ -21,4 +21,4 @@ function FieldMessage(props) {
|
|
|
21
21
|
export {
|
|
22
22
|
FieldMessage
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-YVUZSAJG.js.map
|
|
@@ -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":[]}
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { FieldMessageProps } from './_tsup-dts-rollup';
|
|
|
5
5
|
export { IconButton } from './_tsup-dts-rollup';
|
|
6
6
|
export { IconButtonUsage } from './_tsup-dts-rollup';
|
|
7
7
|
export { IconButtonProps } from './_tsup-dts-rollup';
|
|
8
|
+
export { Input } from './_tsup-dts-rollup';
|
|
9
|
+
export { InputProps } from './_tsup-dts-rollup';
|
|
8
10
|
export { Label } from './_tsup-dts-rollup';
|
|
9
11
|
export { LabelProps } from './_tsup-dts-rollup';
|
|
10
12
|
export { NavMenuTrigger } from './_tsup-dts-rollup';
|
package/build/legacy/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Label
|
|
3
|
+
} from "./chunk-OXVNTE4A.js";
|
|
1
4
|
import {
|
|
2
5
|
NavMenuLink
|
|
3
6
|
} from "./chunk-JA4IX7GN.js";
|
|
@@ -28,25 +31,26 @@ import {
|
|
|
28
31
|
} from "./chunk-XFWARXLU.js";
|
|
29
32
|
import {
|
|
30
33
|
FieldMessage
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-YVUZSAJG.js";
|
|
32
35
|
import {
|
|
33
36
|
IconButton
|
|
34
37
|
} from "./chunk-BPIYUAYS.js";
|
|
35
38
|
import {
|
|
36
|
-
|
|
37
|
-
} from "./chunk-
|
|
39
|
+
Input
|
|
40
|
+
} from "./chunk-LD5ZV46F.js";
|
|
38
41
|
import {
|
|
39
42
|
Show
|
|
40
43
|
} from "./chunk-R4H3352X.js";
|
|
41
44
|
import {
|
|
42
45
|
Field,
|
|
43
46
|
useFieldContext
|
|
44
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
45
48
|
export {
|
|
46
49
|
Button,
|
|
47
50
|
Field,
|
|
48
51
|
FieldMessage,
|
|
49
52
|
IconButton,
|
|
53
|
+
Input,
|
|
50
54
|
Label,
|
|
51
55
|
MODE_KEY,
|
|
52
56
|
NavMenu,
|
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
6
7
|
import { PropsWithChildren } from 'react';
|
|
7
8
|
import { ReactNode } from 'react';
|
|
@@ -49,7 +50,7 @@ export { Field as Field_alias_1 }
|
|
|
49
50
|
|
|
50
51
|
declare interface FieldContextValue {
|
|
51
52
|
disabled?: boolean;
|
|
52
|
-
|
|
53
|
+
readOnly?: boolean;
|
|
53
54
|
required?: boolean;
|
|
54
55
|
invalid?: boolean;
|
|
55
56
|
}
|
|
@@ -120,6 +121,18 @@ declare type IconButtonUsage = Exclude<ButtonProps['usage'], 'outline'>;
|
|
|
120
121
|
export { IconButtonUsage }
|
|
121
122
|
export { IconButtonUsage as IconButtonUsage_alias_1 }
|
|
122
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
|
+
|
|
123
136
|
/**
|
|
124
137
|
* A screen ready friendly label component.
|
|
125
138
|
* @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
|
|
@@ -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":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-R4H3352X.js";
|
|
4
4
|
import {
|
|
5
5
|
useFieldContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
7
|
|
|
8
8
|
// src/components/Label.tsx
|
|
9
9
|
import { label } from "@cerberus/styled-system/recipes";
|
|
@@ -27,14 +27,14 @@ function Label(props) {
|
|
|
27
27
|
),
|
|
28
28
|
children: [
|
|
29
29
|
props.children,
|
|
30
|
-
/* @__PURE__ */ jsx(Show, { when:
|
|
30
|
+
/* @__PURE__ */ jsx(Show, { when: required, children: /* @__PURE__ */ jsx(
|
|
31
31
|
"span",
|
|
32
32
|
{
|
|
33
33
|
className: css({
|
|
34
34
|
color: "neutral.text.100",
|
|
35
35
|
fontSize: "inherit"
|
|
36
36
|
}),
|
|
37
|
-
children: "(
|
|
37
|
+
children: "(required)"
|
|
38
38
|
}
|
|
39
39
|
) })
|
|
40
40
|
]
|
|
@@ -45,4 +45,4 @@ function Label(props) {
|
|
|
45
45
|
export {
|
|
46
46
|
Label
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-OXVNTE4A.js.map
|
|
@@ -1 +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={
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useFieldContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
4
4
|
|
|
5
5
|
// src/components/FieldMessage.tsx
|
|
6
6
|
import { cx } from "@cerberus/styled-system/css";
|
|
@@ -21,4 +21,4 @@ function FieldMessage(props) {
|
|
|
21
21
|
export {
|
|
22
22
|
FieldMessage
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-YVUZSAJG.js.map
|
|
@@ -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":[]}
|
package/build/modern/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { FieldMessageProps } from './_tsup-dts-rollup';
|
|
|
5
5
|
export { IconButton } from './_tsup-dts-rollup';
|
|
6
6
|
export { IconButtonUsage } from './_tsup-dts-rollup';
|
|
7
7
|
export { IconButtonProps } from './_tsup-dts-rollup';
|
|
8
|
+
export { Input } from './_tsup-dts-rollup';
|
|
9
|
+
export { InputProps } from './_tsup-dts-rollup';
|
|
8
10
|
export { Label } from './_tsup-dts-rollup';
|
|
9
11
|
export { LabelProps } from './_tsup-dts-rollup';
|
|
10
12
|
export { NavMenuTrigger } from './_tsup-dts-rollup';
|
package/build/modern/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Label
|
|
3
|
+
} from "./chunk-OXVNTE4A.js";
|
|
1
4
|
import {
|
|
2
5
|
NavMenuLink
|
|
3
6
|
} from "./chunk-JA4IX7GN.js";
|
|
@@ -28,25 +31,26 @@ import {
|
|
|
28
31
|
} from "./chunk-XFWARXLU.js";
|
|
29
32
|
import {
|
|
30
33
|
FieldMessage
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-YVUZSAJG.js";
|
|
32
35
|
import {
|
|
33
36
|
IconButton
|
|
34
37
|
} from "./chunk-BPIYUAYS.js";
|
|
35
38
|
import {
|
|
36
|
-
|
|
37
|
-
} from "./chunk-
|
|
39
|
+
Input
|
|
40
|
+
} from "./chunk-LD5ZV46F.js";
|
|
38
41
|
import {
|
|
39
42
|
Show
|
|
40
43
|
} from "./chunk-R4H3352X.js";
|
|
41
44
|
import {
|
|
42
45
|
Field,
|
|
43
46
|
useFieldContext
|
|
44
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
45
48
|
export {
|
|
46
49
|
Button,
|
|
47
50
|
Field,
|
|
48
51
|
FieldMessage,
|
|
49
52
|
IconButton,
|
|
53
|
+
Input,
|
|
50
54
|
Label,
|
|
51
55
|
MODE_KEY,
|
|
52
56
|
NavMenu,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.1.3-next-
|
|
3
|
+
"version": "0.1.3-next-59f45d9",
|
|
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,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
|
+
}
|
package/src/components/Label.tsx
CHANGED
|
@@ -45,14 +45,14 @@ export function Label(props: PropsWithChildren<LabelProps>) {
|
|
|
45
45
|
)}
|
|
46
46
|
>
|
|
47
47
|
{props.children}
|
|
48
|
-
<Show when={
|
|
48
|
+
<Show when={required}>
|
|
49
49
|
<span
|
|
50
50
|
className={css({
|
|
51
51
|
color: 'neutral.text.100',
|
|
52
52
|
fontSize: 'inherit',
|
|
53
53
|
})}
|
|
54
54
|
>
|
|
55
|
-
(
|
|
55
|
+
(required)
|
|
56
56
|
</span>
|
|
57
57
|
</Show>
|
|
58
58
|
</label>
|
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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
export * from './components/Button'
|
|
9
9
|
export * from './components/FieldMessage'
|
|
10
10
|
export * from './components/IconButton'
|
|
11
|
+
export * from './components/Input'
|
|
11
12
|
export * from './components/Label'
|
|
12
13
|
export * from './components/NavMenuTrigger'
|
|
13
14
|
export * from './components/NavMenuList'
|
|
File without changes
|
|
File without changes
|