@cerberus-design/react 0.0.1-next-a6c2598 → 0.0.1-next-f49bb60
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.cts +17 -0
- package/build/legacy/_tsup-dts-rollup.d.ts +17 -0
- package/build/legacy/context/field.cjs +55 -0
- package/build/legacy/context/field.cjs.map +1 -0
- package/build/legacy/context/field.d.cts +3 -0
- package/build/legacy/context/field.d.ts +3 -0
- package/build/legacy/context/field.js +34 -0
- package/build/legacy/context/field.js.map +1 -0
- package/build/legacy/index.cjs +2 -0
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +3 -0
- package/build/legacy/index.d.ts +3 -0
- package/build/legacy/index.js +1 -0
- package/build/legacy/index.js.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.cts +17 -0
- package/build/modern/_tsup-dts-rollup.d.ts +17 -0
- package/build/modern/context/field.cjs +55 -0
- package/build/modern/context/field.cjs.map +1 -0
- package/build/modern/context/field.d.cts +3 -0
- package/build/modern/context/field.d.ts +3 -0
- package/build/modern/context/field.js +34 -0
- package/build/modern/context/field.js.map +1 -0
- package/build/modern/index.cjs +2 -0
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +3 -0
- package/build/modern/index.d.ts +3 -0
- package/build/modern/index.js +1 -0
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/context/field.tsx +45 -0
- package/src/index.ts +1 -0
|
@@ -38,6 +38,19 @@ declare type DefaultThemes = 'cerberus';
|
|
|
38
38
|
export { DefaultThemes }
|
|
39
39
|
export { DefaultThemes as DefaultThemes_alias_1 }
|
|
40
40
|
|
|
41
|
+
declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
|
|
42
|
+
export { Field }
|
|
43
|
+
export { Field as Field_alias_1 }
|
|
44
|
+
|
|
45
|
+
declare interface FieldContextValue {
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
readonly?: boolean;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
invalid?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export { FieldContextValue }
|
|
52
|
+
export { FieldContextValue as FieldContextValue_alias_1 }
|
|
53
|
+
|
|
41
54
|
declare function getPosition(position: Positions): GetPositionResult;
|
|
42
55
|
export { getPosition }
|
|
43
56
|
export { getPosition as getPosition_alias_1 }
|
|
@@ -193,6 +206,10 @@ declare function ThemeProvider(props: PropsWithChildren<unknown>): JSX.Element;
|
|
|
193
206
|
export { ThemeProvider }
|
|
194
207
|
export { ThemeProvider as ThemeProvider_alias_1 }
|
|
195
208
|
|
|
209
|
+
declare function useFieldContext(): FieldContextValue;
|
|
210
|
+
export { useFieldContext }
|
|
211
|
+
export { useFieldContext as useFieldContext_alias_1 }
|
|
212
|
+
|
|
196
213
|
declare function useNavMenuContext(): NavMenuContextValue;
|
|
197
214
|
export { useNavMenuContext }
|
|
198
215
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
@@ -38,6 +38,19 @@ declare type DefaultThemes = 'cerberus';
|
|
|
38
38
|
export { DefaultThemes }
|
|
39
39
|
export { DefaultThemes as DefaultThemes_alias_1 }
|
|
40
40
|
|
|
41
|
+
declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
|
|
42
|
+
export { Field }
|
|
43
|
+
export { Field as Field_alias_1 }
|
|
44
|
+
|
|
45
|
+
declare interface FieldContextValue {
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
readonly?: boolean;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
invalid?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export { FieldContextValue }
|
|
52
|
+
export { FieldContextValue as FieldContextValue_alias_1 }
|
|
53
|
+
|
|
41
54
|
declare function getPosition(position: Positions): GetPositionResult;
|
|
42
55
|
export { getPosition }
|
|
43
56
|
export { getPosition as getPosition_alias_1 }
|
|
@@ -193,6 +206,10 @@ declare function ThemeProvider(props: PropsWithChildren<unknown>): JSX.Element;
|
|
|
193
206
|
export { ThemeProvider }
|
|
194
207
|
export { ThemeProvider as ThemeProvider_alias_1 }
|
|
195
208
|
|
|
209
|
+
declare function useFieldContext(): FieldContextValue;
|
|
210
|
+
export { useFieldContext }
|
|
211
|
+
export { useFieldContext as useFieldContext_alias_1 }
|
|
212
|
+
|
|
196
213
|
declare function useNavMenuContext(): NavMenuContextValue;
|
|
197
214
|
export { useNavMenuContext }
|
|
198
215
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/context/field.tsx
|
|
22
|
+
var field_exports = {};
|
|
23
|
+
__export(field_exports, {
|
|
24
|
+
Field: () => Field,
|
|
25
|
+
useFieldContext: () => useFieldContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(field_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
var FieldContext = (0, import_react.createContext)(null);
|
|
31
|
+
function Field(props) {
|
|
32
|
+
const value = (0, import_react.useMemo)(
|
|
33
|
+
() => ({
|
|
34
|
+
disabled: props.disabled,
|
|
35
|
+
readonly: props.readonly,
|
|
36
|
+
required: props.required,
|
|
37
|
+
invalid: props.invalid
|
|
38
|
+
}),
|
|
39
|
+
[props.disabled, props.readonly, props.required, props.invalid]
|
|
40
|
+
);
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldContext.Provider, { value, children: props.children });
|
|
42
|
+
}
|
|
43
|
+
function useFieldContext() {
|
|
44
|
+
const context = (0, import_react.useContext)(FieldContext);
|
|
45
|
+
if (!context) {
|
|
46
|
+
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
Field,
|
|
53
|
+
useFieldContext
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=field.cjs.map
|
|
@@ -0,0 +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 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":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAKO;AAyBH;AAhBJ,IAAM,mBAAe,4BAAwC,IAAI;AAE1D,SAAS,MACd,OACa;AACb,QAAM,YAAQ;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,4CAAC,aAAa,UAAb,EAAsB,OACpB,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/context/field.tsx
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo
|
|
8
|
+
} from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var FieldContext = createContext(null);
|
|
11
|
+
function Field(props) {
|
|
12
|
+
const value = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
disabled: props.disabled,
|
|
15
|
+
readonly: props.readonly,
|
|
16
|
+
required: props.required,
|
|
17
|
+
invalid: props.invalid
|
|
18
|
+
}),
|
|
19
|
+
[props.disabled, props.readonly, props.required, props.invalid]
|
|
20
|
+
);
|
|
21
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, { value, children: props.children });
|
|
22
|
+
}
|
|
23
|
+
function useFieldContext() {
|
|
24
|
+
const context = useContext(FieldContext);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
Field,
|
|
32
|
+
useFieldContext
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +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 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":[]}
|
package/build/legacy/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __reExport(src_exports, require("./components/NavMenuTrigger.cjs"), module.expor
|
|
|
22
22
|
__reExport(src_exports, require("./components/NavMenuList.cjs"), module.exports);
|
|
23
23
|
__reExport(src_exports, require("./components/NavMenuLink.cjs"), module.exports);
|
|
24
24
|
__reExport(src_exports, require("./components/Show.cjs"), module.exports);
|
|
25
|
+
__reExport(src_exports, require("./context/field.cjs"), module.exports);
|
|
25
26
|
__reExport(src_exports, require("./context/navMenu.cjs"), module.exports);
|
|
26
27
|
__reExport(src_exports, require("./context/theme.cjs"), module.exports);
|
|
27
28
|
__reExport(src_exports, require("./hooks/useTheme.cjs"), module.exports);
|
|
@@ -34,6 +35,7 @@ __reExport(src_exports, require("./types.cjs"), module.exports);
|
|
|
34
35
|
...require("./components/NavMenuList.cjs"),
|
|
35
36
|
...require("./components/NavMenuLink.cjs"),
|
|
36
37
|
...require("./components/Show.cjs"),
|
|
38
|
+
...require("./context/field.cjs"),
|
|
37
39
|
...require("./context/navMenu.cjs"),
|
|
38
40
|
...require("./context/theme.cjs"),
|
|
39
41
|
...require("./hooks/useTheme.cjs"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,oCAFd;AAGA,wBAAc,4CAHd;AAIA,wBAAc,yCAJd;AAKA,wBAAc,yCALd;AAMA,wBAAc,kCANd;AAUA,wBAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,oCAFd;AAGA,wBAAc,4CAHd;AAIA,wBAAc,yCAJd;AAKA,wBAAc,yCALd;AAMA,wBAAc,kCANd;AAUA,wBAAc,gCAVd;AAWA,wBAAc,kCAXd;AAYA,wBAAc,gCAZd;AAgBA,wBAAc,iCAhBd;AAoBA,wBAAc,6CApBd;AAwBA,wBAAc,wBAxBd;","names":[]}
|
package/build/legacy/index.d.cts
CHANGED
|
@@ -9,6 +9,9 @@ export { NavMenuLink } from './_tsup-dts-rollup';
|
|
|
9
9
|
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
10
10
|
export { Show } from './_tsup-dts-rollup';
|
|
11
11
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
12
|
+
export { Field } from './_tsup-dts-rollup';
|
|
13
|
+
export { useFieldContext } from './_tsup-dts-rollup';
|
|
14
|
+
export { FieldContextValue } from './_tsup-dts-rollup';
|
|
12
15
|
export { NavMenu } from './_tsup-dts-rollup';
|
|
13
16
|
export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
14
17
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export { NavMenuLink } from './_tsup-dts-rollup';
|
|
|
9
9
|
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
10
10
|
export { Show } from './_tsup-dts-rollup';
|
|
11
11
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
12
|
+
export { Field } from './_tsup-dts-rollup';
|
|
13
|
+
export { useFieldContext } from './_tsup-dts-rollup';
|
|
14
|
+
export { FieldContextValue } from './_tsup-dts-rollup';
|
|
12
15
|
export { NavMenu } from './_tsup-dts-rollup';
|
|
13
16
|
export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
14
17
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
package/build/legacy/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/NavMenuTrigger.js";
|
|
|
4
4
|
export * from "./components/NavMenuList.js";
|
|
5
5
|
export * from "./components/NavMenuLink.js";
|
|
6
6
|
export * from "./components/Show.js";
|
|
7
|
+
export * from "./context/field.js";
|
|
7
8
|
export * from "./context/navMenu.js";
|
|
8
9
|
export * from "./context/theme.js";
|
|
9
10
|
export * from "./hooks/useTheme.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";AAEA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AAId,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";AAEA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
|
@@ -38,6 +38,19 @@ declare type DefaultThemes = 'cerberus';
|
|
|
38
38
|
export { DefaultThemes }
|
|
39
39
|
export { DefaultThemes as DefaultThemes_alias_1 }
|
|
40
40
|
|
|
41
|
+
declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
|
|
42
|
+
export { Field }
|
|
43
|
+
export { Field as Field_alias_1 }
|
|
44
|
+
|
|
45
|
+
declare interface FieldContextValue {
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
readonly?: boolean;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
invalid?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export { FieldContextValue }
|
|
52
|
+
export { FieldContextValue as FieldContextValue_alias_1 }
|
|
53
|
+
|
|
41
54
|
declare function getPosition(position: Positions): GetPositionResult;
|
|
42
55
|
export { getPosition }
|
|
43
56
|
export { getPosition as getPosition_alias_1 }
|
|
@@ -193,6 +206,10 @@ declare function ThemeProvider(props: PropsWithChildren<unknown>): JSX.Element;
|
|
|
193
206
|
export { ThemeProvider }
|
|
194
207
|
export { ThemeProvider as ThemeProvider_alias_1 }
|
|
195
208
|
|
|
209
|
+
declare function useFieldContext(): FieldContextValue;
|
|
210
|
+
export { useFieldContext }
|
|
211
|
+
export { useFieldContext as useFieldContext_alias_1 }
|
|
212
|
+
|
|
196
213
|
declare function useNavMenuContext(): NavMenuContextValue;
|
|
197
214
|
export { useNavMenuContext }
|
|
198
215
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
@@ -38,6 +38,19 @@ declare type DefaultThemes = 'cerberus';
|
|
|
38
38
|
export { DefaultThemes }
|
|
39
39
|
export { DefaultThemes as DefaultThemes_alias_1 }
|
|
40
40
|
|
|
41
|
+
declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
|
|
42
|
+
export { Field }
|
|
43
|
+
export { Field as Field_alias_1 }
|
|
44
|
+
|
|
45
|
+
declare interface FieldContextValue {
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
readonly?: boolean;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
invalid?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export { FieldContextValue }
|
|
52
|
+
export { FieldContextValue as FieldContextValue_alias_1 }
|
|
53
|
+
|
|
41
54
|
declare function getPosition(position: Positions): GetPositionResult;
|
|
42
55
|
export { getPosition }
|
|
43
56
|
export { getPosition as getPosition_alias_1 }
|
|
@@ -193,6 +206,10 @@ declare function ThemeProvider(props: PropsWithChildren<unknown>): JSX.Element;
|
|
|
193
206
|
export { ThemeProvider }
|
|
194
207
|
export { ThemeProvider as ThemeProvider_alias_1 }
|
|
195
208
|
|
|
209
|
+
declare function useFieldContext(): FieldContextValue;
|
|
210
|
+
export { useFieldContext }
|
|
211
|
+
export { useFieldContext as useFieldContext_alias_1 }
|
|
212
|
+
|
|
196
213
|
declare function useNavMenuContext(): NavMenuContextValue;
|
|
197
214
|
export { useNavMenuContext }
|
|
198
215
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/context/field.tsx
|
|
22
|
+
var field_exports = {};
|
|
23
|
+
__export(field_exports, {
|
|
24
|
+
Field: () => Field,
|
|
25
|
+
useFieldContext: () => useFieldContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(field_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
var FieldContext = (0, import_react.createContext)(null);
|
|
31
|
+
function Field(props) {
|
|
32
|
+
const value = (0, import_react.useMemo)(
|
|
33
|
+
() => ({
|
|
34
|
+
disabled: props.disabled,
|
|
35
|
+
readonly: props.readonly,
|
|
36
|
+
required: props.required,
|
|
37
|
+
invalid: props.invalid
|
|
38
|
+
}),
|
|
39
|
+
[props.disabled, props.readonly, props.required, props.invalid]
|
|
40
|
+
);
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldContext.Provider, { value, children: props.children });
|
|
42
|
+
}
|
|
43
|
+
function useFieldContext() {
|
|
44
|
+
const context = (0, import_react.useContext)(FieldContext);
|
|
45
|
+
if (!context) {
|
|
46
|
+
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
Field,
|
|
53
|
+
useFieldContext
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=field.cjs.map
|
|
@@ -0,0 +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 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":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAKO;AAyBH;AAhBJ,IAAM,mBAAe,4BAAwC,IAAI;AAE1D,SAAS,MACd,OACa;AACb,QAAM,YAAQ;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,4CAAC,aAAa,UAAb,EAAsB,OACpB,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/context/field.tsx
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo
|
|
8
|
+
} from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var FieldContext = createContext(null);
|
|
11
|
+
function Field(props) {
|
|
12
|
+
const value = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
disabled: props.disabled,
|
|
15
|
+
readonly: props.readonly,
|
|
16
|
+
required: props.required,
|
|
17
|
+
invalid: props.invalid
|
|
18
|
+
}),
|
|
19
|
+
[props.disabled, props.readonly, props.required, props.invalid]
|
|
20
|
+
);
|
|
21
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, { value, children: props.children });
|
|
22
|
+
}
|
|
23
|
+
function useFieldContext() {
|
|
24
|
+
const context = useContext(FieldContext);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
Field,
|
|
32
|
+
useFieldContext
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +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 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":[]}
|
package/build/modern/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __reExport(src_exports, require("./components/NavMenuTrigger.cjs"), module.expor
|
|
|
22
22
|
__reExport(src_exports, require("./components/NavMenuList.cjs"), module.exports);
|
|
23
23
|
__reExport(src_exports, require("./components/NavMenuLink.cjs"), module.exports);
|
|
24
24
|
__reExport(src_exports, require("./components/Show.cjs"), module.exports);
|
|
25
|
+
__reExport(src_exports, require("./context/field.cjs"), module.exports);
|
|
25
26
|
__reExport(src_exports, require("./context/navMenu.cjs"), module.exports);
|
|
26
27
|
__reExport(src_exports, require("./context/theme.cjs"), module.exports);
|
|
27
28
|
__reExport(src_exports, require("./hooks/useTheme.cjs"), module.exports);
|
|
@@ -34,6 +35,7 @@ __reExport(src_exports, require("./types.cjs"), module.exports);
|
|
|
34
35
|
...require("./components/NavMenuList.cjs"),
|
|
35
36
|
...require("./components/NavMenuLink.cjs"),
|
|
36
37
|
...require("./components/Show.cjs"),
|
|
38
|
+
...require("./context/field.cjs"),
|
|
37
39
|
...require("./context/navMenu.cjs"),
|
|
38
40
|
...require("./context/theme.cjs"),
|
|
39
41
|
...require("./hooks/useTheme.cjs"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,oCAFd;AAGA,wBAAc,4CAHd;AAIA,wBAAc,yCAJd;AAKA,wBAAc,yCALd;AAMA,wBAAc,kCANd;AAUA,wBAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,oCAFd;AAGA,wBAAc,4CAHd;AAIA,wBAAc,yCAJd;AAKA,wBAAc,yCALd;AAMA,wBAAc,kCANd;AAUA,wBAAc,gCAVd;AAWA,wBAAc,kCAXd;AAYA,wBAAc,gCAZd;AAgBA,wBAAc,iCAhBd;AAoBA,wBAAc,6CApBd;AAwBA,wBAAc,wBAxBd;","names":[]}
|
package/build/modern/index.d.cts
CHANGED
|
@@ -9,6 +9,9 @@ export { NavMenuLink } from './_tsup-dts-rollup';
|
|
|
9
9
|
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
10
10
|
export { Show } from './_tsup-dts-rollup';
|
|
11
11
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
12
|
+
export { Field } from './_tsup-dts-rollup';
|
|
13
|
+
export { useFieldContext } from './_tsup-dts-rollup';
|
|
14
|
+
export { FieldContextValue } from './_tsup-dts-rollup';
|
|
12
15
|
export { NavMenu } from './_tsup-dts-rollup';
|
|
13
16
|
export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
14
17
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
package/build/modern/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export { NavMenuLink } from './_tsup-dts-rollup';
|
|
|
9
9
|
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
10
10
|
export { Show } from './_tsup-dts-rollup';
|
|
11
11
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
12
|
+
export { Field } from './_tsup-dts-rollup';
|
|
13
|
+
export { useFieldContext } from './_tsup-dts-rollup';
|
|
14
|
+
export { FieldContextValue } from './_tsup-dts-rollup';
|
|
12
15
|
export { NavMenu } from './_tsup-dts-rollup';
|
|
13
16
|
export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
14
17
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
package/build/modern/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/NavMenuTrigger.js";
|
|
|
4
4
|
export * from "./components/NavMenuList.js";
|
|
5
5
|
export * from "./components/NavMenuLink.js";
|
|
6
6
|
export * from "./components/Show.js";
|
|
7
|
+
export * from "./context/field.js";
|
|
7
8
|
export * from "./context/navMenu.js";
|
|
8
9
|
export * from "./context/theme.js";
|
|
9
10
|
export * from "./hooks/useTheme.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";AAEA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AAId,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";AAEA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.0.1-next-
|
|
3
|
+
"version": "0.0.1-next-f49bb60",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"react-dom": "^18",
|
|
22
22
|
"tsup": "^8.0.2",
|
|
23
23
|
"@cerberus-design/configs": "0.0.0",
|
|
24
|
-
"@cerberus-design/styled-system": "0.0.1-next-
|
|
24
|
+
"@cerberus-design/styled-system": "0.0.1-next-f49bb60"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useMemo,
|
|
7
|
+
type PropsWithChildren,
|
|
8
|
+
} from 'react'
|
|
9
|
+
|
|
10
|
+
export interface FieldContextValue {
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
readonly?: boolean
|
|
13
|
+
required?: boolean
|
|
14
|
+
invalid?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const FieldContext = createContext<FieldContextValue | null>(null)
|
|
18
|
+
|
|
19
|
+
export function Field(
|
|
20
|
+
props: PropsWithChildren<FieldContextValue>,
|
|
21
|
+
): JSX.Element {
|
|
22
|
+
const value = useMemo(
|
|
23
|
+
() => ({
|
|
24
|
+
disabled: props.disabled,
|
|
25
|
+
readonly: props.readonly,
|
|
26
|
+
required: props.required,
|
|
27
|
+
invalid: props.invalid,
|
|
28
|
+
}),
|
|
29
|
+
[props.disabled, props.readonly, props.required, props.invalid],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<FieldContext.Provider value={value}>
|
|
34
|
+
{props.children}
|
|
35
|
+
</FieldContext.Provider>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function useFieldContext(): FieldContextValue {
|
|
40
|
+
const context = useContext(FieldContext)
|
|
41
|
+
if (!context) {
|
|
42
|
+
throw new Error('useFieldContext must be used within a Field Provider.')
|
|
43
|
+
}
|
|
44
|
+
return context
|
|
45
|
+
}
|