@okam/next-component 2.1.0 → 2.1.1

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 (45) hide show
  1. package/components/AdminBar/AdminBarContent.d.ts +3 -0
  2. package/components/AdminBar/AdminBarContent.js +14 -0
  3. package/components/AdminBar/AdminBarContent.mjs +14 -0
  4. package/components/AdminBar/index.js +14 -0
  5. package/components/AdminBar/index.mjs +15 -0
  6. package/components/Filter/index.js +54 -0
  7. package/components/Filter/index.mjs +55 -0
  8. package/components/Img/index.js +29 -0
  9. package/components/Img/index.mjs +30 -0
  10. package/components/Link/index.js +40 -0
  11. package/components/Link/index.mjs +41 -0
  12. package/hooks/useFilterState/index.js +50 -0
  13. package/hooks/useFilterState/index.mjs +50 -0
  14. package/hooks/useHash/index.js +25 -0
  15. package/hooks/useHash/index.mjs +25 -0
  16. package/hooks/useLink/index.js +118 -0
  17. package/hooks/useLink/index.mjs +118 -0
  18. package/hooks/useLink/interface.d.ts +61 -1
  19. package/hooks/useLink/interface.js +8 -0
  20. package/hooks/useLink/interface.mjs +8 -0
  21. package/index.d.ts +2 -1
  22. package/index.js +20 -590
  23. package/index.mjs +17 -587
  24. package/lib/createServerContext/index.js +12 -0
  25. package/lib/createServerContext/index.mjs +12 -0
  26. package/package.json +5 -5
  27. package/providers/AdminBar/index.js +17 -0
  28. package/providers/AdminBar/index.mjs +17 -0
  29. package/{index-DV6W6v68.js → providers/DraftMode/index.js} +2 -0
  30. package/{index-Ber8Ecgv.mjs → providers/DraftMode/index.mjs} +3 -2
  31. package/providers/DraftMode/server.js +10 -0
  32. package/providers/DraftMode/server.mjs +11 -0
  33. package/server.d.ts +1 -0
  34. package/server.js +8 -30
  35. package/server.mjs +7 -29
  36. package/theme/AdminBar/index.js +120 -0
  37. package/theme/AdminBar/index.mjs +120 -0
  38. package/theme/Button/index.js +75 -0
  39. package/theme/Button/index.mjs +76 -0
  40. package/theme/Filter/index.js +72 -0
  41. package/theme/Filter/index.mjs +73 -0
  42. package/theme/Typography/index.js +43 -0
  43. package/theme/Typography/index.mjs +44 -0
  44. package/theme/index.js +16 -0
  45. package/theme/index.mjs +17 -0
package/index.mjs CHANGED
@@ -1,593 +1,23 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Box, PopoverButton, TagGroup, useThemeContext, Anchor, createThemeProvider, makeTheme } from "@okam/stack-ui";
3
- import { parseAsArrayOf, parseAsString, useQueryState } from "nuqs";
4
- import { isEqual } from "radashi";
5
- import { useMemo, useState, useRef, useCallback, useEffect, memo } from "react";
6
- import { useListState } from "react-stately";
7
- import { useUpdateEffect, useEvent } from "react-use";
8
- import Image from "next/image";
9
- import NextLink from "next/link";
10
- import { usePathname, useSearchParams, useParams } from "next/navigation";
11
- import { useLocale } from "react-aria";
12
- import { createCtx } from "@okam/react-utils";
13
- import { D, u } from "./index-Ber8Ecgv.mjs";
14
- import { tv } from "tailwind-variants";
15
- function useFilterState(props) {
16
- const {
17
- id,
18
- defaultSelectedKeys: defaultSelectedKeysProp = [],
19
- onSelectionChange,
20
- selectionMode = "multiple",
21
- parser = parseAsArrayOf(parseAsString),
22
- children,
23
- items,
24
- options,
25
- ...rest
26
- } = props;
27
- const defaultValue = Array.from(defaultSelectedKeysProp).map((key) => key.toString());
28
- const queryStateOptions = useMemo(
29
- () => parser.withOptions(options ?? {}).withDefault(defaultValue),
30
- [parser, options, defaultValue]
31
- );
32
- const [selectedKeys, setSelectedKeys] = useQueryState(id, queryStateOptions);
33
- const onSelectedKeysChange = (keys) => {
34
- onSelectionChange?.(keys);
35
- const stringKeys = Array.from(keys).map((key) => key.toString());
36
- void setSelectedKeys(stringKeys);
37
- };
38
- const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
39
- const state = useListState({
40
- ...rest,
41
- children,
42
- items,
43
- selectionMode,
44
- defaultSelectedKeys,
45
- onSelectionChange: onSelectedKeysChange
46
- });
47
- useUpdateEffect(() => {
48
- const next = [...state.selectionManager.selectedKeys].map(String);
49
- if (isEqual(next, selectedKeys)) {
50
- return;
51
- }
52
- void setSelectedKeys(next);
53
- }, [state.selectionManager.selectedKeys]);
54
- return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys: selectedKeys ?? void 0, defaultSelectedKeys };
55
- }
56
- function Filter(props) {
57
- const {
58
- // TagGroup-specific props
59
- children,
60
- items,
61
- defaultSelectedKeys,
62
- selectedKeys,
63
- selectionBehavior,
64
- selectionMode = "multiple",
65
- options,
66
- description,
67
- disabledKeys,
68
- disallowEmptySelection,
69
- errorMessage,
70
- onRemove,
71
- onSelectionChange,
72
- // Common props
73
- themeName = "filter",
74
- tokens,
75
- customTheme,
76
- // PopoverButton props with defaults
77
- type = "dialog",
78
- placement = "bottom",
79
- // Remaining PopoverButton props
80
- ...popoverButtonProps
81
- } = props;
82
- const tagGroupProps = {
83
- items,
84
- selectionBehavior,
85
- selectionMode,
86
- description,
87
- disallowEmptySelection,
88
- errorMessage,
89
- onRemove
90
- };
91
- const state = useFilterState({ ...props, selectionMode });
92
- return /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.wrapper`, tokens, customTheme, children: /* @__PURE__ */ jsx(
93
- PopoverButton,
94
- {
95
- themeName: `${themeName}.popover`,
96
- tokens,
97
- type,
98
- placement,
99
- ...popoverButtonProps,
100
- children: /* @__PURE__ */ jsx(TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
101
- }
102
- ) });
103
- }
104
- function Img(props) {
105
- const { src, width, height, themeName = "img", tokens, customTheme, ...rest } = props;
106
- const theme = useThemeContext(themeName, tokens, customTheme);
107
- if (typeof src === "object") {
108
- const { blurWidth, blurHeight, width: srcWidth, height: srcHeight, ...withoutBlurDimensions } = src;
109
- const blur = {
110
- blurwidth: blurWidth,
111
- blurheight: blurHeight
112
- };
113
- return /* @__PURE__ */ jsx(
114
- Image,
115
- {
116
- className: theme,
117
- ...withoutBlurDimensions,
118
- ...rest,
119
- ...blur,
120
- width: srcWidth ?? width,
121
- height: srcHeight ?? height
122
- }
123
- );
124
- }
125
- return /* @__PURE__ */ jsx(Image, { width, height, className: theme, src, ...rest });
126
- }
127
- function getHash() {
128
- if (typeof window === "undefined")
129
- return "";
130
- return window.location.hash;
131
- }
132
- function useHash() {
133
- const defaultHash = getHash();
134
- const [hash, setHash] = useState(defaultHash);
135
- const handleHashChangeEvent = ({ newURL }) => {
136
- if (!URL.canParse(newURL))
137
- return;
138
- const { hash: newHash } = new URL(newURL);
139
- if (!newHash || newHash === hash)
140
- return;
141
- setHash(newHash);
142
- };
143
- useEvent("hashchange", handleHashChangeEvent);
144
- return hash;
145
- }
146
- function scrollToTop(behavior) {
147
- window?.scrollTo?.({ top: 0, behavior });
148
- }
149
- function getParamsLocale(params) {
150
- const { locale } = params ?? {};
151
- if (Array.isArray(locale))
152
- return locale[0];
153
- return locale;
154
- }
155
- function useLinkLocale(props) {
156
- const { locale } = props;
157
- const params = useParams();
158
- const paramsLocale = getParamsLocale(params);
159
- const { locale: ctxLocale } = useLocale();
160
- return locale ?? ctxLocale ?? paramsLocale ?? false;
161
- }
162
- function localizeHref(href, locale) {
163
- const hrefString = href.toString();
164
- const isAnchor = hrefString.startsWith("#");
165
- const isExternal = /^[a-z]+:\/\//i.test(hrefString) || hrefString.startsWith("//");
166
- if (isExternal || isAnchor)
167
- return hrefString;
168
- if (locale != null && locale !== false) {
169
- return `/${locale}${hrefString}`;
170
- }
171
- return hrefString;
172
- }
173
- function useLink(props) {
174
- const {
175
- scroll = true,
176
- onMouseEnter,
177
- onTouchStart,
178
- onClick,
179
- onNavigate,
180
- onPathnameChange,
181
- onHashChange,
182
- onSearchParamsChange,
183
- href,
184
- urlDecorator,
185
- replace,
186
- prefetch,
187
- shallow,
188
- passHref,
189
- legacyBehavior,
190
- behavior = "instant"
191
- } = props;
192
- const locale = useLinkLocale(props);
193
- const localizedHref = localizeHref(href, locale);
194
- const pathname = usePathname();
195
- const searchParams = useSearchParams();
196
- const hash = useHash();
197
- const hasWarnedOnPathnameChangeRef = useRef(false);
198
- const isNextScroll = typeof scroll === "boolean";
199
- const nextScroll = isNextScroll ? scroll : false;
200
- const handleScroll = useCallback(() => {
201
- if (isNextScroll)
202
- return;
203
- scrollToTop(behavior);
204
- }, [behavior, isNextScroll]);
205
- const handleClick = (event) => {
206
- onClick?.(event);
207
- handleScroll();
208
- };
209
- const handleTouchStart = (event) => {
210
- onTouchStart?.(event);
211
- handleScroll();
212
- };
213
- useEffect(() => {
214
- if (process.env.NODE_ENV === "production" || onPathnameChange == null || hasWarnedOnPathnameChangeRef.current)
215
- return;
216
- console.warn("[next-component/Link] `onPathnameChange` is deprecated and will be removed in the next major version. Use `onNavigate` from next/link instead.");
217
- hasWarnedOnPathnameChangeRef.current = true;
218
- }, [onPathnameChange]);
219
- useEffect(() => {
220
- onPathnameChange?.(pathname);
221
- }, [onPathnameChange, pathname]);
222
- useEffect(() => {
223
- onSearchParamsChange?.(searchParams);
224
- }, [onSearchParamsChange, searchParams]);
225
- useEffect(() => {
226
- onHashChange?.(hash);
227
- }, [onHashChange, hash]);
228
- return {
229
- href: localizedHref.toString(),
230
- as: urlDecorator,
231
- replace,
232
- prefetch,
233
- shallow,
234
- onClick: handleClick,
235
- onNavigate,
236
- onTouchStart: handleTouchStart,
237
- onMouseEnter,
238
- scroll: nextScroll,
239
- passHref,
240
- legacyBehavior
241
- };
242
- }
243
- function Link({ ref, ...props }) {
244
- const {
245
- themeName = "link",
246
- tokens,
247
- customTheme,
248
- as = NextLink,
249
- children,
250
- locale,
251
- scroll,
252
- onPathnameChange,
253
- onSearchParamsChange,
254
- onHashChange,
255
- behavior,
256
- urlDecorator: urlDecoratorProp,
257
- href: hrefProp,
258
- ...rest
259
- } = props;
260
- const linkProps = useLink(props);
261
- return /* @__PURE__ */ jsx(
262
- Anchor,
263
- {
264
- ref,
265
- ...rest,
266
- nextLinkProps: linkProps,
267
- as,
268
- themeName,
269
- tokens,
270
- customTheme,
271
- children
272
- }
273
- );
274
- }
275
- Link.displayName = "Link";
276
- const adminBarCtx = createCtx();
277
- const useAdminBar = adminBarCtx[0];
278
- const AdminBarProvider = adminBarCtx[1];
279
- function AdminBarContextProvider(props) {
280
- const { children } = props;
281
- const [error, setError] = useState();
282
- const value = useMemo(() => ({ error, setError }), [error]);
283
- return /* @__PURE__ */ jsx(AdminBarProvider, { value, children });
284
- }
285
- const adminBarContainer = tv({
286
- base: "w-full bg-gray-100 py-2 px-4 border-gray-200 fixed left-0 right-0 z-50",
287
- variants: {
288
- position: {
289
- top: "top-0 border-b",
290
- bottom: "bottom-0 border-t"
291
- },
292
- fullWidth: {
293
- true: "max-w-full"
294
- },
295
- background: {
296
- grey: "bg-gray-100",
297
- dark: "bg-gray-800 text-white",
298
- light: "bg-white"
299
- },
300
- padding: {
301
- small: "py-1 px-2",
302
- medium: "py-2 px-4",
303
- large: "py-3 px-6"
304
- }
305
- },
306
- defaultVariants: {
307
- position: "top",
308
- background: "grey",
309
- padding: "medium"
310
- }
311
- });
312
- const adminBarContent = tv({
313
- base: "flex items-center",
314
- variants: {
315
- justify: {
316
- start: "justify-start",
317
- center: "justify-center",
318
- end: "justify-end",
319
- between: "justify-between",
320
- around: "justify-around",
321
- evenly: "justify-evenly"
322
- },
323
- gap: {
324
- small: "gap-2",
325
- medium: "gap-4",
326
- large: "gap-6"
327
- },
328
- wrap: {
329
- true: "flex-wrap",
330
- false: "flex-nowrap"
331
- }
332
- },
333
- defaultVariants: {
334
- justify: "between",
335
- gap: "medium",
336
- wrap: false
337
- }
338
- });
339
- const adminBarButton = tv({
340
- base: "px-3 py-1 rounded text-sm font-medium transition-colors",
341
- variants: {
342
- variant: {
343
- primary: "bg-blue-600 text-white hover:bg-blue-700",
344
- secondary: "bg-gray-200 text-gray-800 hover:bg-gray-300",
345
- danger: "bg-red-600 text-white hover:bg-red-700"
346
- },
347
- size: {
348
- small: "text-xs px-2 py-0.5",
349
- medium: "text-sm px-3 py-1",
350
- large: "text-base px-4 py-2"
351
- }
352
- },
353
- defaultVariants: {
354
- variant: "secondary",
355
- size: "medium"
356
- }
357
- });
358
- const adminBarError = tv({
359
- base: "flex items-center justify-center bg-red-50 text-red-700 px-3 py-1 rounded-md text-sm",
360
- variants: {
361
- severity: {
362
- low: "bg-yellow-50 text-yellow-700",
363
- medium: "bg-red-50 text-red-700",
364
- high: "bg-red-100 text-red-800 font-bold"
365
- },
366
- hasBorder: {
367
- true: "border border-red-300",
368
- false: ""
369
- }
370
- },
371
- defaultVariants: {
372
- severity: "medium",
373
- hasBorder: true
374
- }
375
- });
376
- const adminBarErrorTypography = tv({
377
- base: "text-red-700 text-sm font-medium",
378
- variants: {
379
- severity: {
380
- low: "text-yellow-700",
381
- medium: "text-red-700",
382
- high: "text-red-800 font-bold"
383
- }
384
- },
385
- defaultVariants: {
386
- severity: "medium"
387
- }
388
- });
389
- const adminBarTheme = {
390
- container: adminBarContainer,
391
- content: adminBarContent,
392
- button: adminBarButton,
393
- error: adminBarError,
394
- errorTypography: adminBarErrorTypography
395
- };
396
- const button = tv({
397
- base: `
398
- flex
399
- items-center
400
- justify-center
401
- gap-4
402
- transition
403
- duration-300
404
- ease-in-out
405
- disabled:pointer-events-none
406
- disabled:opacity-30
407
- focus-ring-black
408
- `,
409
- defaultVariants: {
410
- buttonStyle: "default",
411
- type: "button",
412
- size: "default",
413
- shape: "rounded"
414
- },
415
- variants: {
416
- type: {
417
- button: "",
418
- menu: "text-2xl"
419
- },
420
- buttonStyle: {
421
- default: `
422
- px-4
423
- py-2
424
- text-white
425
- !bg-color-1-500
426
- hover:!bg-color-1-400
427
- active:!bg-color-1-400
428
- `,
429
- outline: `
430
- px-4
431
- py-2
432
- bg-transparent
433
- !border-color-1-500
434
- border-2
435
- text-color-1-500
436
- hover:bg-color-1-500
437
- hover:text-white
438
- active:bg-color-1-500
439
- active:text-white
440
- `,
441
- hollow: `
442
- px-2
443
- bg-transparent
444
- text-color-1-500
445
- hover:border-b-color-1-500
446
- active:border-b-color-1-500
447
- focus:border-b-color-1-500
448
- `
449
- },
450
- intent: {
451
- error: `
452
- !bg-error
453
- text-white
454
- pointer-events-none
455
- !border-error
456
- `
457
- },
458
- size: {
459
- default: `min-w-12 min-h-6`,
460
- large: `min-w-36 min-h-18`
461
- },
462
- shape: {
463
- rounded: `rounded-md`,
464
- circular: `rounded-full`
465
- }
466
- }
467
- });
468
- const typography = tv({
469
- variants: {
470
- size: {
471
- h1: `text-5xl`,
472
- h2: `text-4xl`,
473
- h3: `text-3xl`,
474
- h4: `text-2xl`,
475
- h5: `text-xl`,
476
- h6: `text-lg`,
477
- leading: `text-md font-bold leading-normal`,
478
- paragraph: `text-md inline`,
479
- footnotes: `text-sm`,
480
- xs: `text-xs`
481
- },
482
- font: {
483
- body: `font-body`
484
- },
485
- weight: {
486
- normal: `font-normal`,
487
- light: `font-light`,
488
- bold: "font-bold"
489
- },
490
- color: {
491
- gray: `text-gray-500`,
492
- white: `text-white`
493
- },
494
- isError: {
495
- true: "text-sm text-error py-3"
496
- },
497
- align: {
498
- center: "text-center",
499
- left: "text-left",
500
- right: "text-right"
501
- }
502
- },
503
- defaultVariants: {
504
- size: "paragraph",
505
- font: "body"
506
- }
507
- });
508
- const filterTagGroupWrapper = tv({
509
- base: "w-full flex flex-col gap-2"
510
- });
511
- const filterTagGroupTags = tv({
512
- base: "flex flex-col gap-2 max-w-[150px] items-center mx-auto"
513
- });
514
- const filterTagGroupLabel = tv({
515
- extend: typography,
516
- defaultVariants: { size: "h4" }
517
- });
518
- const filterTagGroupDescription = tv({
519
- extend: typography,
520
- base: "block",
521
- defaultVariants: { size: "footnotes" }
522
- });
523
- const filterTagGroupErrorMessage = tv({
524
- extend: typography,
525
- base: "block",
526
- defaultVariants: { isError: true }
527
- });
528
- const filterTagGroupTagWrapper = tv({
529
- base: [
530
- button({ buttonStyle: "outline" }),
531
- `
532
- focus-visible:outline
533
- focus-visible:outline-offset-2
534
- focus-visible:outline-2
535
- focus-visible:outline-black
536
- `
537
- ],
538
- variants: {
539
- isSelected: {
540
- true: [button({ buttonStyle: "default" })]
541
- },
542
- isDisabled: {
543
- true: "pointer-events-none opacity-30"
544
- }
545
- }
546
- });
547
- const filterTagGroupTagContainer = tv({
548
- extend: typography,
549
- base: "flex items-center justify-center"
550
- });
551
- const filterPopoverButton = tv({
552
- extend: button,
553
- base: "!min-w-[200px]"
554
- });
555
- const filterPopoverPopover = tv({
556
- base: "w-[var(--filter-popover-container-width)] bg-gray-300 rounded-md p-4"
557
- });
558
- const filterTheme = {
559
- popover: {
560
- button: filterPopoverButton,
561
- popover: filterPopoverPopover
562
- },
563
- tagGroup: {
564
- wrapper: filterTagGroupWrapper,
565
- tags: filterTagGroupTags,
566
- label: filterTagGroupLabel,
567
- description: filterTagGroupDescription,
568
- errorMessage: filterTagGroupErrorMessage,
569
- tag: {
570
- wrapper: filterTagGroupTagWrapper,
571
- container: filterTagGroupTagContainer
572
- }
573
- }
574
- };
575
- const BaseTheme = makeTheme({
576
- filter: filterTheme,
577
- button,
578
- typography,
579
- adminBar: adminBarTheme
580
- });
581
- const index = memo(createThemeProvider(BaseTheme));
1
+ import { default as default2 } from "./components/Filter/index.mjs";
2
+ import { default as default3 } from "./components/Img/index.mjs";
3
+ import { default as default4 } from "./components/Link/index.mjs";
4
+ import { useFilterState } from "./hooks/useFilterState/index.mjs";
5
+ import { useHash } from "./hooks/useHash/index.mjs";
6
+ import { useLink } from "./hooks/useLink/index.mjs";
7
+ import { LocalePrefix } from "./hooks/useLink/interface.mjs";
8
+ import { AdminBarContextProvider, useAdminBar } from "./providers/AdminBar/index.mjs";
9
+ import { DraftModeContextProvider, useDraftMode } from "./providers/DraftMode/index.mjs";
10
+ import { default as default5 } from "./theme/index.mjs";
582
11
  export {
583
12
  AdminBarContextProvider,
584
- D as DraftModeContextProvider,
585
- Filter,
586
- Img,
587
- Link,
588
- index as ThemeProvider,
13
+ DraftModeContextProvider,
14
+ default2 as Filter,
15
+ default3 as Img,
16
+ default4 as Link,
17
+ LocalePrefix,
18
+ default5 as ThemeProvider,
589
19
  useAdminBar,
590
- u as useDraftMode,
20
+ useDraftMode,
591
21
  useFilterState,
592
22
  useHash,
593
23
  useLink
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,12 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/next-component",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "repository": {
5
5
  "url": "https://github.com/OKAMca/stack.git"
6
6
  },
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "require": {
20
20
  "types": "./index.d.ts",
21
- "default": "./index.mjs"
21
+ "default": "./index.js"
22
22
  }
23
23
  },
24
24
  "./server": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "require": {
30
30
  "types": "./server.d.ts",
31
- "default": "./server.mjs"
31
+ "default": "./server.js"
32
32
  }
33
33
  }
34
34
  },
@@ -43,8 +43,8 @@
43
43
  "react-stately": "^3.43.0"
44
44
  },
45
45
  "dependencies": {
46
- "@okam/react-utils": "0.0.1",
47
- "@okam/stack-ui": "2.0.3",
46
+ "@okam/react-utils": "1.0.0",
47
+ "@okam/stack-ui": "2.1.1",
48
48
  "nuqs": "^2.4.3",
49
49
  "radashi": "^12.3.0",
50
50
  "react-aria": "^3.39.0",
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createCtx } from "@okam/react-utils";
4
+ import { useState, useMemo } from "react";
5
+ const adminBarCtx = createCtx();
6
+ const useAdminBar = adminBarCtx[0];
7
+ const AdminBarProvider = adminBarCtx[1];
8
+ function AdminBarContextProvider(props) {
9
+ const { children } = props;
10
+ const [error, setError] = useState();
11
+ const value = useMemo(() => ({ error, setError }), [error]);
12
+ return /* @__PURE__ */ jsx(AdminBarProvider, { value, children });
13
+ }
14
+ export {
15
+ AdminBarContextProvider,
16
+ useAdminBar
17
+ };