@okam/next-component 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/hooks/useLink/interface.d.ts +4 -1
  3. package/{providers/DraftMode/index.mjs → index-Ber8Ecgv.mjs} +2 -3
  4. package/{providers/DraftMode/index.js → index-DV6W6v68.js} +0 -2
  5. package/index.js +590 -18
  6. package/index.mjs +587 -15
  7. package/package.json +2 -3
  8. package/server.js +31 -7
  9. package/server.mjs +30 -6
  10. package/components/AdminBar/index.js +0 -14
  11. package/components/AdminBar/index.mjs +0 -15
  12. package/components/Filter/index.js +0 -54
  13. package/components/Filter/index.mjs +0 -55
  14. package/components/Img/index.js +0 -29
  15. package/components/Img/index.mjs +0 -30
  16. package/components/Link/index.js +0 -39
  17. package/components/Link/index.mjs +0 -40
  18. package/hooks/useFilterState/index.js +0 -50
  19. package/hooks/useFilterState/index.mjs +0 -50
  20. package/hooks/useHash/index.js +0 -25
  21. package/hooks/useHash/index.mjs +0 -25
  22. package/hooks/useLink/index.js +0 -99
  23. package/hooks/useLink/index.mjs +0 -99
  24. package/lib/createServerContext/index.js +0 -12
  25. package/lib/createServerContext/index.mjs +0 -12
  26. package/providers/AdminBar/index.js +0 -17
  27. package/providers/AdminBar/index.mjs +0 -17
  28. package/providers/DraftMode/server.js +0 -10
  29. package/providers/DraftMode/server.mjs +0 -11
  30. package/theme/AdminBar/index.js +0 -120
  31. package/theme/AdminBar/index.mjs +0 -120
  32. package/theme/Button/index.js +0 -75
  33. package/theme/Button/index.mjs +0 -76
  34. package/theme/Filter/index.js +0 -72
  35. package/theme/Filter/index.mjs +0 -73
  36. package/theme/Typography/index.js +0 -43
  37. package/theme/Typography/index.mjs +0 -44
  38. package/theme/index.js +0 -16
  39. package/theme/index.mjs +0 -17
@@ -1,14 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const stackUi = require("@okam/stack-ui");
4
- const headers = require("next/headers");
5
- async function AdminBar({
6
- children,
7
- themeName = "adminBar",
8
- tokens,
9
- customTheme
10
- }) {
11
- const { isEnabled } = await headers.draftMode();
12
- return isEnabled && /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.container`, tokens, customTheme, children: /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.content`, tokens, children }) });
13
- }
14
- module.exports = AdminBar;
@@ -1,15 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Box } from "@okam/stack-ui";
3
- import { draftMode } from "next/headers";
4
- async function AdminBar({
5
- children,
6
- themeName = "adminBar",
7
- tokens,
8
- customTheme
9
- }) {
10
- const { isEnabled } = await draftMode();
11
- return isEnabled && /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.container`, tokens, customTheme, children: /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.content`, tokens, children }) });
12
- }
13
- export {
14
- AdminBar as default
15
- };
@@ -1,54 +0,0 @@
1
- "use client";
2
- "use strict";
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const stackUi = require("@okam/stack-ui");
5
- const index = require("../../hooks/useFilterState/index.js");
6
- function Filter(props) {
7
- const {
8
- // TagGroup-specific props
9
- children,
10
- items,
11
- defaultSelectedKeys,
12
- selectedKeys,
13
- selectionBehavior,
14
- selectionMode = "multiple",
15
- options,
16
- description,
17
- disabledKeys,
18
- disallowEmptySelection,
19
- errorMessage,
20
- onRemove,
21
- onSelectionChange,
22
- // Common props
23
- themeName = "filter",
24
- tokens,
25
- customTheme,
26
- // PopoverButton props with defaults
27
- type = "dialog",
28
- placement = "bottom",
29
- // Remaining PopoverButton props
30
- ...popoverButtonProps
31
- } = props;
32
- const tagGroupProps = {
33
- items,
34
- selectionBehavior,
35
- selectionMode,
36
- description,
37
- disallowEmptySelection,
38
- errorMessage,
39
- onRemove
40
- };
41
- const state = index.useFilterState({ ...props, selectionMode });
42
- return /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.wrapper`, tokens, customTheme, children: /* @__PURE__ */ jsxRuntime.jsx(
43
- stackUi.PopoverButton,
44
- {
45
- themeName: `${themeName}.popover`,
46
- tokens,
47
- type,
48
- placement,
49
- ...popoverButtonProps,
50
- children: /* @__PURE__ */ jsxRuntime.jsx(stackUi.TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
51
- }
52
- ) });
53
- }
54
- module.exports = Filter;
@@ -1,55 +0,0 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { Box, PopoverButton, TagGroup } from "@okam/stack-ui";
4
- import { useFilterState } from "../../hooks/useFilterState/index.mjs";
5
- function Filter(props) {
6
- const {
7
- // TagGroup-specific props
8
- children,
9
- items,
10
- defaultSelectedKeys,
11
- selectedKeys,
12
- selectionBehavior,
13
- selectionMode = "multiple",
14
- options,
15
- description,
16
- disabledKeys,
17
- disallowEmptySelection,
18
- errorMessage,
19
- onRemove,
20
- onSelectionChange,
21
- // Common props
22
- themeName = "filter",
23
- tokens,
24
- customTheme,
25
- // PopoverButton props with defaults
26
- type = "dialog",
27
- placement = "bottom",
28
- // Remaining PopoverButton props
29
- ...popoverButtonProps
30
- } = props;
31
- const tagGroupProps = {
32
- items,
33
- selectionBehavior,
34
- selectionMode,
35
- description,
36
- disallowEmptySelection,
37
- errorMessage,
38
- onRemove
39
- };
40
- const state = useFilterState({ ...props, selectionMode });
41
- return /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.wrapper`, tokens, customTheme, children: /* @__PURE__ */ jsx(
42
- PopoverButton,
43
- {
44
- themeName: `${themeName}.popover`,
45
- tokens,
46
- type,
47
- placement,
48
- ...popoverButtonProps,
49
- children: /* @__PURE__ */ jsx(TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
50
- }
51
- ) });
52
- }
53
- export {
54
- Filter as default
55
- };
@@ -1,29 +0,0 @@
1
- "use client";
2
- "use strict";
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const stackUi = require("@okam/stack-ui");
5
- const Image = require("next/image");
6
- function Img(props) {
7
- const { src, width, height, themeName = "img", tokens, customTheme, ...rest } = props;
8
- const theme = stackUi.useThemeContext(themeName, tokens, customTheme);
9
- if (typeof src === "object") {
10
- const { blurWidth, blurHeight, width: srcWidth, height: srcHeight, ...withoutBlurDimensions } = src;
11
- const blur = {
12
- blurwidth: blurWidth,
13
- blurheight: blurHeight
14
- };
15
- return /* @__PURE__ */ jsxRuntime.jsx(
16
- Image,
17
- {
18
- className: theme,
19
- ...withoutBlurDimensions,
20
- ...rest,
21
- ...blur,
22
- width: srcWidth ?? width,
23
- height: srcHeight ?? height
24
- }
25
- );
26
- }
27
- return /* @__PURE__ */ jsxRuntime.jsx(Image, { width, height, className: theme, src, ...rest });
28
- }
29
- module.exports = Img;
@@ -1,30 +0,0 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { useThemeContext } from "@okam/stack-ui";
4
- import Image from "next/image";
5
- function Img(props) {
6
- const { src, width, height, themeName = "img", tokens, customTheme, ...rest } = props;
7
- const theme = useThemeContext(themeName, tokens, customTheme);
8
- if (typeof src === "object") {
9
- const { blurWidth, blurHeight, width: srcWidth, height: srcHeight, ...withoutBlurDimensions } = src;
10
- const blur = {
11
- blurwidth: blurWidth,
12
- blurheight: blurHeight
13
- };
14
- return /* @__PURE__ */ jsx(
15
- Image,
16
- {
17
- className: theme,
18
- ...withoutBlurDimensions,
19
- ...rest,
20
- ...blur,
21
- width: srcWidth ?? width,
22
- height: srcHeight ?? height
23
- }
24
- );
25
- }
26
- return /* @__PURE__ */ jsx(Image, { width, height, className: theme, src, ...rest });
27
- }
28
- export {
29
- Img as default
30
- };
@@ -1,39 +0,0 @@
1
- "use client";
2
- "use strict";
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const stackUi = require("@okam/stack-ui");
5
- const NextLink = require("next/link");
6
- const index = require("../../hooks/useLink/index.js");
7
- function Link({ ref, ...props }) {
8
- const {
9
- themeName = "link",
10
- tokens,
11
- customTheme,
12
- as = NextLink,
13
- children,
14
- scroll,
15
- onPathnameChange,
16
- onSearchParamsChange,
17
- onHashChange,
18
- behavior,
19
- urlDecorator: urlDecoratorProp,
20
- href: hrefProp,
21
- ...rest
22
- } = props;
23
- const linkProps = index.useLink(props);
24
- return /* @__PURE__ */ jsxRuntime.jsx(
25
- stackUi.Anchor,
26
- {
27
- ref,
28
- ...rest,
29
- nextLinkProps: linkProps,
30
- as,
31
- themeName,
32
- tokens,
33
- customTheme,
34
- children
35
- }
36
- );
37
- }
38
- Link.displayName = "Link";
39
- module.exports = Link;
@@ -1,40 +0,0 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { Anchor } from "@okam/stack-ui";
4
- import NextLink from "next/link";
5
- import { useLink } from "../../hooks/useLink/index.mjs";
6
- function Link({ ref, ...props }) {
7
- const {
8
- themeName = "link",
9
- tokens,
10
- customTheme,
11
- as = NextLink,
12
- children,
13
- scroll,
14
- onPathnameChange,
15
- onSearchParamsChange,
16
- onHashChange,
17
- behavior,
18
- urlDecorator: urlDecoratorProp,
19
- href: hrefProp,
20
- ...rest
21
- } = props;
22
- const linkProps = useLink(props);
23
- return /* @__PURE__ */ jsx(
24
- Anchor,
25
- {
26
- ref,
27
- ...rest,
28
- nextLinkProps: linkProps,
29
- as,
30
- themeName,
31
- tokens,
32
- customTheme,
33
- children
34
- }
35
- );
36
- }
37
- Link.displayName = "Link";
38
- export {
39
- Link as default
40
- };
@@ -1,50 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const nuqs = require("nuqs");
5
- const radashi = require("radashi");
6
- const react = require("react");
7
- const reactStately = require("react-stately");
8
- const reactUse = require("react-use");
9
- function useFilterState(props) {
10
- const {
11
- id,
12
- defaultSelectedKeys: defaultSelectedKeysProp = [],
13
- onSelectionChange,
14
- selectionMode = "multiple",
15
- parser = nuqs.parseAsArrayOf(nuqs.parseAsString),
16
- children,
17
- items,
18
- options,
19
- ...rest
20
- } = props;
21
- const defaultValue = Array.from(defaultSelectedKeysProp).map((key) => key.toString());
22
- const queryStateOptions = react.useMemo(
23
- () => parser.withOptions(options ?? {}).withDefault(defaultValue),
24
- [parser, options, defaultValue]
25
- );
26
- const [selectedKeys, setSelectedKeys] = nuqs.useQueryState(id, queryStateOptions);
27
- const onSelectedKeysChange = (keys) => {
28
- onSelectionChange?.(keys);
29
- const stringKeys = Array.from(keys).map((key) => key.toString());
30
- void setSelectedKeys(stringKeys);
31
- };
32
- const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
33
- const state = reactStately.useListState({
34
- ...rest,
35
- children,
36
- items,
37
- selectionMode,
38
- defaultSelectedKeys,
39
- onSelectionChange: onSelectedKeysChange
40
- });
41
- reactUse.useUpdateEffect(() => {
42
- const next = [...state.selectionManager.selectedKeys].map(String);
43
- if (radashi.isEqual(next, selectedKeys)) {
44
- return;
45
- }
46
- void setSelectedKeys(next);
47
- }, [state.selectionManager.selectedKeys]);
48
- return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys: selectedKeys ?? void 0, defaultSelectedKeys };
49
- }
50
- exports.useFilterState = useFilterState;
@@ -1,50 +0,0 @@
1
- "use client";
2
- import { parseAsArrayOf, parseAsString, useQueryState } from "nuqs";
3
- import { isEqual } from "radashi";
4
- import { useMemo } from "react";
5
- import { useListState } from "react-stately";
6
- import { useUpdateEffect } from "react-use";
7
- function useFilterState(props) {
8
- const {
9
- id,
10
- defaultSelectedKeys: defaultSelectedKeysProp = [],
11
- onSelectionChange,
12
- selectionMode = "multiple",
13
- parser = parseAsArrayOf(parseAsString),
14
- children,
15
- items,
16
- options,
17
- ...rest
18
- } = props;
19
- const defaultValue = Array.from(defaultSelectedKeysProp).map((key) => key.toString());
20
- const queryStateOptions = useMemo(
21
- () => parser.withOptions(options ?? {}).withDefault(defaultValue),
22
- [parser, options, defaultValue]
23
- );
24
- const [selectedKeys, setSelectedKeys] = useQueryState(id, queryStateOptions);
25
- const onSelectedKeysChange = (keys) => {
26
- onSelectionChange?.(keys);
27
- const stringKeys = Array.from(keys).map((key) => key.toString());
28
- void setSelectedKeys(stringKeys);
29
- };
30
- const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
31
- const state = useListState({
32
- ...rest,
33
- children,
34
- items,
35
- selectionMode,
36
- defaultSelectedKeys,
37
- onSelectionChange: onSelectedKeysChange
38
- });
39
- useUpdateEffect(() => {
40
- const next = [...state.selectionManager.selectedKeys].map(String);
41
- if (isEqual(next, selectedKeys)) {
42
- return;
43
- }
44
- void setSelectedKeys(next);
45
- }, [state.selectionManager.selectedKeys]);
46
- return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys: selectedKeys ?? void 0, defaultSelectedKeys };
47
- }
48
- export {
49
- useFilterState
50
- };
@@ -1,25 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const react = require("react");
5
- const reactUse = require("react-use");
6
- function getHash() {
7
- if (typeof window === "undefined")
8
- return "";
9
- return window.location.hash;
10
- }
11
- function useHash() {
12
- const defaultHash = getHash();
13
- const [hash, setHash] = react.useState(defaultHash);
14
- const handleHashChangeEvent = ({ newURL }) => {
15
- if (!URL.canParse(newURL))
16
- return;
17
- const { hash: newHash } = new URL(newURL);
18
- if (!newHash || newHash === hash)
19
- return;
20
- setHash(newHash);
21
- };
22
- reactUse.useEvent("hashchange", handleHashChangeEvent);
23
- return hash;
24
- }
25
- exports.useHash = useHash;
@@ -1,25 +0,0 @@
1
- "use client";
2
- import { useState } from "react";
3
- import { useEvent } from "react-use";
4
- function getHash() {
5
- if (typeof window === "undefined")
6
- return "";
7
- return window.location.hash;
8
- }
9
- function useHash() {
10
- const defaultHash = getHash();
11
- const [hash, setHash] = useState(defaultHash);
12
- const handleHashChangeEvent = ({ newURL }) => {
13
- if (!URL.canParse(newURL))
14
- return;
15
- const { hash: newHash } = new URL(newURL);
16
- if (!newHash || newHash === hash)
17
- return;
18
- setHash(newHash);
19
- };
20
- useEvent("hashchange", handleHashChangeEvent);
21
- return hash;
22
- }
23
- export {
24
- useHash
25
- };
@@ -1,99 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const navigation = require("next/navigation");
5
- const react = require("react");
6
- const reactAria = require("react-aria");
7
- const index = require("../useHash/index.js");
8
- function scrollToTop(behavior) {
9
- window?.scrollTo?.({ top: 0, behavior });
10
- }
11
- function getParamsLocale(params) {
12
- const { locale } = params ?? {};
13
- if (Array.isArray(locale))
14
- return locale[0];
15
- return locale;
16
- }
17
- function useLinkLocale(props) {
18
- const { locale } = props;
19
- const params = navigation.useParams();
20
- const paramsLocale = getParamsLocale(params);
21
- const { locale: ctxLocale } = reactAria.useLocale();
22
- return locale ?? ctxLocale ?? paramsLocale ?? false;
23
- }
24
- function localizeHref(href, locale) {
25
- const hrefString = href.toString();
26
- const isAnchor = hrefString.startsWith("#");
27
- const isExternal = /^[a-z]+:\/\//i.test(hrefString) || hrefString.startsWith("//");
28
- if (isExternal || isAnchor)
29
- return hrefString;
30
- if (locale != null && locale !== false) {
31
- return `/${locale}${hrefString}`;
32
- }
33
- return hrefString;
34
- }
35
- function useLink(props) {
36
- const {
37
- scroll = true,
38
- onMouseEnter,
39
- onTouchStart,
40
- onClick,
41
- onPathnameChange,
42
- onHashChange,
43
- onSearchParamsChange,
44
- href,
45
- urlDecorator,
46
- replace,
47
- prefetch,
48
- shallow,
49
- passHref,
50
- legacyBehavior,
51
- behavior = "instant"
52
- } = props;
53
- const locale = useLinkLocale(props);
54
- const localizedHref = localizeHref(href, locale);
55
- const pathname = navigation.usePathname();
56
- const searchParams = navigation.useSearchParams();
57
- const hash = index.useHash();
58
- const isNextScroll = typeof scroll === "boolean";
59
- const nextScroll = isNextScroll ? scroll : false;
60
- const handleScroll = react.useCallback(() => {
61
- if (isNextScroll)
62
- return;
63
- scrollToTop(behavior);
64
- }, [behavior, isNextScroll]);
65
- const handleClick = (event) => {
66
- onClick?.(event);
67
- handleScroll();
68
- };
69
- const handleTouchStart = (event) => {
70
- onTouchStart?.(event);
71
- handleScroll();
72
- };
73
- react.useEffect(() => {
74
- onPathnameChange?.(pathname);
75
- }, [onPathnameChange, pathname]);
76
- react.useEffect(() => {
77
- onSearchParamsChange?.(searchParams);
78
- }, [onSearchParamsChange, searchParams]);
79
- react.useEffect(() => {
80
- onHashChange?.(hash);
81
- }, [onHashChange, hash]);
82
- return {
83
- href: localizedHref.toString(),
84
- as: urlDecorator,
85
- replace,
86
- locale,
87
- prefetch,
88
- shallow,
89
- onClick: handleClick,
90
- onTouchStart: handleTouchStart,
91
- onMouseEnter,
92
- scroll: nextScroll,
93
- passHref,
94
- legacyBehavior
95
- };
96
- }
97
- exports.localizeHref = localizeHref;
98
- exports.useLink = useLink;
99
- exports.useLinkLocale = useLinkLocale;
@@ -1,99 +0,0 @@
1
- "use client";
2
- import { usePathname, useSearchParams, useParams } from "next/navigation";
3
- import { useCallback, useEffect } from "react";
4
- import { useLocale } from "react-aria";
5
- import { useHash } from "../useHash/index.mjs";
6
- function scrollToTop(behavior) {
7
- window?.scrollTo?.({ top: 0, behavior });
8
- }
9
- function getParamsLocale(params) {
10
- const { locale } = params ?? {};
11
- if (Array.isArray(locale))
12
- return locale[0];
13
- return locale;
14
- }
15
- function useLinkLocale(props) {
16
- const { locale } = props;
17
- const params = useParams();
18
- const paramsLocale = getParamsLocale(params);
19
- const { locale: ctxLocale } = useLocale();
20
- return locale ?? ctxLocale ?? paramsLocale ?? false;
21
- }
22
- function localizeHref(href, locale) {
23
- const hrefString = href.toString();
24
- const isAnchor = hrefString.startsWith("#");
25
- const isExternal = /^[a-z]+:\/\//i.test(hrefString) || hrefString.startsWith("//");
26
- if (isExternal || isAnchor)
27
- return hrefString;
28
- if (locale != null && locale !== false) {
29
- return `/${locale}${hrefString}`;
30
- }
31
- return hrefString;
32
- }
33
- function useLink(props) {
34
- const {
35
- scroll = true,
36
- onMouseEnter,
37
- onTouchStart,
38
- onClick,
39
- onPathnameChange,
40
- onHashChange,
41
- onSearchParamsChange,
42
- href,
43
- urlDecorator,
44
- replace,
45
- prefetch,
46
- shallow,
47
- passHref,
48
- legacyBehavior,
49
- behavior = "instant"
50
- } = props;
51
- const locale = useLinkLocale(props);
52
- const localizedHref = localizeHref(href, locale);
53
- const pathname = usePathname();
54
- const searchParams = useSearchParams();
55
- const hash = useHash();
56
- const isNextScroll = typeof scroll === "boolean";
57
- const nextScroll = isNextScroll ? scroll : false;
58
- const handleScroll = useCallback(() => {
59
- if (isNextScroll)
60
- return;
61
- scrollToTop(behavior);
62
- }, [behavior, isNextScroll]);
63
- const handleClick = (event) => {
64
- onClick?.(event);
65
- handleScroll();
66
- };
67
- const handleTouchStart = (event) => {
68
- onTouchStart?.(event);
69
- handleScroll();
70
- };
71
- useEffect(() => {
72
- onPathnameChange?.(pathname);
73
- }, [onPathnameChange, pathname]);
74
- useEffect(() => {
75
- onSearchParamsChange?.(searchParams);
76
- }, [onSearchParamsChange, searchParams]);
77
- useEffect(() => {
78
- onHashChange?.(hash);
79
- }, [onHashChange, hash]);
80
- return {
81
- href: localizedHref.toString(),
82
- as: urlDecorator,
83
- replace,
84
- locale,
85
- prefetch,
86
- shallow,
87
- onClick: handleClick,
88
- onTouchStart: handleTouchStart,
89
- onMouseEnter,
90
- scroll: nextScroll,
91
- passHref,
92
- legacyBehavior
93
- };
94
- }
95
- export {
96
- localizeHref,
97
- useLink,
98
- useLinkLocale
99
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
4
- function createServerContext(defaultValue) {
5
- const getRef = react.cache(() => ({ current: defaultValue }));
6
- const getValue = () => getRef().current;
7
- const setValue = (value) => {
8
- getRef().current = value;
9
- };
10
- return [getValue, setValue];
11
- }
12
- exports.createServerContext = createServerContext;
@@ -1,12 +0,0 @@
1
- import { cache } from "react";
2
- function createServerContext(defaultValue) {
3
- const getRef = cache(() => ({ current: defaultValue }));
4
- const getValue = () => getRef().current;
5
- const setValue = (value) => {
6
- getRef().current = value;
7
- };
8
- return [getValue, setValue];
9
- }
10
- export {
11
- createServerContext
12
- };
@@ -1,17 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("react/jsx-runtime");
5
- const reactUtils = require("@okam/react-utils");
6
- const react = require("react");
7
- const adminBarCtx = reactUtils.createCtx();
8
- const useAdminBar = adminBarCtx[0];
9
- const AdminBarProvider = adminBarCtx[1];
10
- function AdminBarContextProvider(props) {
11
- const { children } = props;
12
- const [error, setError] = react.useState();
13
- const value = react.useMemo(() => ({ error, setError }), [error]);
14
- return /* @__PURE__ */ jsxRuntime.jsx(AdminBarProvider, { value, children });
15
- }
16
- exports.AdminBarContextProvider = AdminBarContextProvider;
17
- exports.useAdminBar = useAdminBar;