@optiaxiom/globals 1.1.3 → 1.1.5

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/dist/cjs/index.js CHANGED
@@ -8,7 +8,57 @@ const AxiomVersionContext = react.createContext(void 0);
8
8
 
9
9
  const [ModalProvider, useModalContext] = reactContext.createContext("@optiaxiom/react/Modal", { shardRef: { current: null } });
10
10
 
11
- const [unstable_SurfaceProvider, unstable_useSurfaceContext] = reactContext.createContext("@optiaxiom/globals/Surface", null);
11
+ const SuggestionContext = react.createContext(null);
12
+ const SurfaceContext = react.createContext(null);
13
+ const SurfaceProvider = ({
14
+ accept,
15
+ children,
16
+ executeTool,
17
+ reject,
18
+ renderSuggestionValue,
19
+ ...props
20
+ }) => {
21
+ const suggestion = props.suggestions.find(
22
+ (s) => s.type !== "cards" && ("/" + props.path).endsWith("/" + s.surface)
23
+ );
24
+ const store = react.useContext(SuggestionContext);
25
+ react.useEffect(() => {
26
+ if (!store || !suggestion || suggestion.type === "cards" || props.suggestionAlert.registered || props.suggestionPopover.registered) {
27
+ return;
28
+ }
29
+ return store.add(suggestion, {
30
+ accept,
31
+ executeTool,
32
+ reject,
33
+ renderSuggestionValue
34
+ });
35
+ }, [
36
+ accept,
37
+ executeTool,
38
+ props.suggestionAlert.registered,
39
+ props.suggestionPopover.registered,
40
+ reject,
41
+ renderSuggestionValue,
42
+ store,
43
+ suggestion
44
+ ]);
45
+ return react.createElement(SurfaceContext.Provider, {
46
+ children,
47
+ value: {
48
+ accept,
49
+ executeTool,
50
+ reject,
51
+ renderSuggestionValue,
52
+ ...props
53
+ }
54
+ });
55
+ };
56
+ function useSurfaceContext() {
57
+ return react.useContext(SurfaceContext);
58
+ }
59
+ const unstable_SuggestionContext = SuggestionContext;
60
+ const unstable_SurfaceProvider = SurfaceProvider;
61
+ const unstable_useSurfaceContext = useSurfaceContext;
12
62
 
13
63
  var theme = {borderRadius:{xs:'var(--ax-borderRadius-xs)',sm:'var(--ax-borderRadius-sm)',md:'var(--ax-borderRadius-md)',lg:'var(--ax-borderRadius-lg)',xl:'var(--ax-borderRadius-xl)',full:'var(--ax-borderRadius-full)'},boxShadow:{sm:'var(--ax-boxShadow-sm)',md:'var(--ax-boxShadow-md)',lg:'var(--ax-boxShadow-lg)'},colors:{'bg.accent':'var(--ax-colors-bg-accent)','bg.accent.hovered':'var(--ax-colors-bg-accent-hovered)','bg.accent.light':'var(--ax-colors-bg-accent-light)','bg.accent.pressed':'var(--ax-colors-bg-accent-pressed)','bg.accent.subtle':'var(--ax-colors-bg-accent-subtle)','bg.avatar.neutral':'var(--ax-colors-bg-avatar-neutral)','bg.avatar.purple':'var(--ax-colors-bg-avatar-purple)','bg.default':'var(--ax-colors-bg-default)','bg.default.hovered':'var(--ax-colors-bg-default-hovered)','bg.default.inverse':'var(--ax-colors-bg-default-inverse)','bg.default.inverse.hovered':'var(--ax-colors-bg-default-inverse-hovered)','bg.default.inverse.pressed':'var(--ax-colors-bg-default-inverse-pressed)','bg.default.pressed':'var(--ax-colors-bg-default-pressed)','bg.error':'var(--ax-colors-bg-error)','bg.error.hovered':'var(--ax-colors-bg-error-hovered)','bg.error.light':'var(--ax-colors-bg-error-light)','bg.error.pressed':'var(--ax-colors-bg-error-pressed)','bg.error.subtle':'var(--ax-colors-bg-error-subtle)','bg.error.subtlest':'var(--ax-colors-bg-error-subtlest)','bg.information':'var(--ax-colors-bg-information)','bg.information.light':'var(--ax-colors-bg-information-light)','bg.information.subtle':'var(--ax-colors-bg-information-subtle)','bg.overlay':'var(--ax-colors-bg-overlay)','bg.page':'var(--ax-colors-bg-page)','bg.secondary':'var(--ax-colors-bg-secondary)','bg.secondary.hovered':'var(--ax-colors-bg-secondary-hovered)','bg.spinner.default':'var(--ax-colors-bg-spinner-default)','bg.spinner.inverse':'var(--ax-colors-bg-spinner-inverse)','bg.success':'var(--ax-colors-bg-success)','bg.success.hovered':'var(--ax-colors-bg-success-hovered)','bg.success.light':'var(--ax-colors-bg-success-light)','bg.success.subtle':'var(--ax-colors-bg-success-subtle)','bg.tertiary':'var(--ax-colors-bg-tertiary)','bg.tertiary.hovered':'var(--ax-colors-bg-tertiary-hovered)','bg.warning':'var(--ax-colors-bg-warning)','bg.warning.hovered':'var(--ax-colors-bg-warning-hovered)','bg.warning.light':'var(--ax-colors-bg-warning-light)','bg.warning.subtle':'var(--ax-colors-bg-warning-subtle)','border.accent':'var(--ax-colors-border-accent)','border.control':'var(--ax-colors-border-control)','border.control.hovered':'var(--ax-colors-border-control-hovered)','border.default':'var(--ax-colors-border-default)','border.disabled':'var(--ax-colors-border-disabled)','border.error':'var(--ax-colors-border-error)','border.focus':'var(--ax-colors-border-focus)','border.focus.error':'var(--ax-colors-border-focus-error)','border.secondary':'var(--ax-colors-border-secondary)','border.success':'var(--ax-colors-border-success)','border.tertiary':'var(--ax-colors-border-tertiary)','border.warning':'var(--ax-colors-border-warning)','fg.accent':'var(--ax-colors-fg-accent)','fg.accent.hovered':'var(--ax-colors-fg-accent-hovered)','fg.accent.strong':'var(--ax-colors-fg-accent-strong)','fg.avatar.neutral':'var(--ax-colors-fg-avatar-neutral)','fg.avatar.purple':'var(--ax-colors-fg-avatar-purple)','fg.default':'var(--ax-colors-fg-default)','fg.default.inverse':'var(--ax-colors-fg-default-inverse)','fg.disabled':'var(--ax-colors-fg-disabled)','fg.error':'var(--ax-colors-fg-error)','fg.error.hovered':'var(--ax-colors-fg-error-hovered)','fg.error.light':'var(--ax-colors-fg-error-light)','fg.error.strong':'var(--ax-colors-fg-error-strong)','fg.information':'var(--ax-colors-fg-information)','fg.information.light':'var(--ax-colors-fg-information-light)','fg.information.strong':'var(--ax-colors-fg-information-strong)','fg.link.default':'var(--ax-colors-fg-link-default)','fg.link.default.hovered':'var(--ax-colors-fg-link-default-hovered)','fg.link.inverse':'var(--ax-colors-fg-link-inverse)','fg.link.subtle':'var(--ax-colors-fg-link-subtle)','fg.link.visited':'var(--ax-colors-fg-link-visited)','fg.secondary':'var(--ax-colors-fg-secondary)','fg.spinner.default':'var(--ax-colors-fg-spinner-default)','fg.spinner.inverse':'var(--ax-colors-fg-spinner-inverse)','fg.success':'var(--ax-colors-fg-success)','fg.success.hovered':'var(--ax-colors-fg-success-hovered)','fg.success.light':'var(--ax-colors-fg-success-light)','fg.success.strong':'var(--ax-colors-fg-success-strong)','fg.tertiary':'var(--ax-colors-fg-tertiary)','fg.warning':'var(--ax-colors-fg-warning)','fg.warning.hovered':'var(--ax-colors-fg-warning-hovered)','fg.warning.inverse':'var(--ax-colors-fg-warning-inverse)','fg.warning.light':'var(--ax-colors-fg-warning-light)','fg.warning.strong':'var(--ax-colors-fg-warning-strong)','fg.white':'var(--ax-colors-fg-white)'},duration:{sm:'var(--ax-duration-sm)',md:'var(--ax-duration-md)',lg:'var(--ax-duration-lg)'},fontFamily:{mono:'var(--ax-fontFamily-mono)',sans:'var(--ax-fontFamily-sans)'},fontSize:{xs:{fontSize:'var(--ax-fontSize-xs-fontSize)',lineHeight:'var(--ax-fontSize-xs-lineHeight)'},sm:{fontSize:'var(--ax-fontSize-sm-fontSize)',lineHeight:'var(--ax-fontSize-sm-lineHeight)'},md:{fontSize:'var(--ax-fontSize-md-fontSize)',lineHeight:'var(--ax-fontSize-md-lineHeight)'},lg:{fontSize:'var(--ax-fontSize-lg-fontSize)',lineHeight:'var(--ax-fontSize-lg-lineHeight)'},xl:{fontSize:'var(--ax-fontSize-xl-fontSize)',lineHeight:'var(--ax-fontSize-xl-lineHeight)'},'2xl':{fontSize:'var(--ax-fontSize-2xl-fontSize)',lineHeight:'var(--ax-fontSize-2xl-lineHeight)'},'3xl':{fontSize:'var(--ax-fontSize-3xl-fontSize)',lineHeight:'var(--ax-fontSize-3xl-lineHeight)'},'4xl':{fontSize:'var(--ax-fontSize-4xl-fontSize)',lineHeight:'var(--ax-fontSize-4xl-lineHeight)'}},maxSize:{xs:'var(--ax-maxSize-xs)',sm:'var(--ax-maxSize-sm)',md:'var(--ax-maxSize-md)',lg:'var(--ax-maxSize-lg)'},screens:{sm:'var(--ax-screens-sm)',md:'var(--ax-screens-md)'},size:{'2xs':'var(--ax-size-2xs)',xs:'var(--ax-size-xs)',sm:'var(--ax-size-sm)',md:'var(--ax-size-md)',lg:'var(--ax-size-lg)',xl:'var(--ax-size-xl)','3xl':'var(--ax-size-3xl)'},zIndex:{popover:'var(--ax-zIndex-popover)',toast:'var(--ax-zIndex-toast)',tooltip:'var(--ax-zIndex-tooltip)'}};
14
64
 
@@ -363,6 +413,7 @@ exports.createToaster = createToaster;
363
413
  exports.theme = theme;
364
414
  exports.toaster = toaster;
365
415
  exports.tokens = tokens;
416
+ exports.unstable_SuggestionContext = unstable_SuggestionContext;
366
417
  exports.unstable_SurfaceProvider = unstable_SurfaceProvider;
367
418
  exports.unstable_useSurfaceContext = unstable_useSurfaceContext;
368
419
  exports.useModalContext = useModalContext;
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { AxiomAuthContext, AxiomVersionContext } from './context.js';
2
2
  export { ModalProvider, useModalContext } from './modal-context.js';
3
- export { unstable_SurfaceProvider, unstable_useSurfaceContext } from './surface-context.js';
3
+ export { unstable_SuggestionContext, unstable_SurfaceProvider, unstable_useSurfaceContext } from './surface-context.js';
4
4
  export { theme } from './theme-css.js';
5
5
  export { ToastProviderProvider, useToastProviderContext } from './toast-context.js';
6
6
  export { createToaster, toaster } from './toaster.js';
@@ -1,5 +1,56 @@
1
- import { createContext } from '@radix-ui/react-context';
1
+ "use client";
2
+ import { createContext, useContext, useEffect, createElement } from 'react';
2
3
 
3
- const [unstable_SurfaceProvider, unstable_useSurfaceContext] = createContext("@optiaxiom/globals/Surface", null);
4
+ const SuggestionContext = createContext(null);
5
+ const SurfaceContext = createContext(null);
6
+ const SurfaceProvider = ({
7
+ accept,
8
+ children,
9
+ executeTool,
10
+ reject,
11
+ renderSuggestionValue,
12
+ ...props
13
+ }) => {
14
+ const suggestion = props.suggestions.find(
15
+ (s) => s.type !== "cards" && ("/" + props.path).endsWith("/" + s.surface)
16
+ );
17
+ const store = useContext(SuggestionContext);
18
+ useEffect(() => {
19
+ if (!store || !suggestion || suggestion.type === "cards" || props.suggestionAlert.registered || props.suggestionPopover.registered) {
20
+ return;
21
+ }
22
+ return store.add(suggestion, {
23
+ accept,
24
+ executeTool,
25
+ reject,
26
+ renderSuggestionValue
27
+ });
28
+ }, [
29
+ accept,
30
+ executeTool,
31
+ props.suggestionAlert.registered,
32
+ props.suggestionPopover.registered,
33
+ reject,
34
+ renderSuggestionValue,
35
+ store,
36
+ suggestion
37
+ ]);
38
+ return createElement(SurfaceContext.Provider, {
39
+ children,
40
+ value: {
41
+ accept,
42
+ executeTool,
43
+ reject,
44
+ renderSuggestionValue,
45
+ ...props
46
+ }
47
+ });
48
+ };
49
+ function useSurfaceContext() {
50
+ return useContext(SurfaceContext);
51
+ }
52
+ const unstable_SuggestionContext = SuggestionContext;
53
+ const unstable_SurfaceProvider = SurfaceProvider;
54
+ const unstable_useSurfaceContext = useSurfaceContext;
4
55
 
5
- export { unstable_SurfaceProvider, unstable_useSurfaceContext };
56
+ export { unstable_SuggestionContext, unstable_SurfaceProvider, unstable_useSurfaceContext };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { RefObject } from 'react';
2
+ import { RefObject, ReactNode } from 'react';
3
3
 
4
4
  declare const AxiomAuthContext: react.Context<{
5
5
  /**
@@ -49,6 +49,10 @@ type SurfaceContextValue = {
49
49
  path: string;
50
50
  reject: (suggestionId: string) => void;
51
51
  renderSuggestionValue?: (value: unknown) => React.ReactNode;
52
+ suggestionAlert: {
53
+ register: () => () => void;
54
+ registered: boolean;
55
+ };
52
56
  suggestionPopover: {
53
57
  register: () => () => void;
54
58
  registered: boolean;
@@ -105,10 +109,16 @@ type SurfaceSuggestion = {
105
109
  };
106
110
  type: "message";
107
111
  });
108
- declare const unstable_SurfaceProvider: react.FC<SurfaceContextValue & {
109
- children: React.ReactNode;
110
- }>;
111
- declare const unstable_useSurfaceContext: (consumerName: string) => SurfaceContextValue | null;
112
+ declare function useSurfaceContext(): SurfaceContextValue | null;
113
+ declare const unstable_SuggestionContext: react.Context<{
114
+ add: (suggestion: Extract<SurfaceSuggestion, {
115
+ type: "message" | "value";
116
+ }>, surface: Pick<SurfaceContextValue, "accept" | "executeTool" | "reject" | "renderSuggestionValue">) => () => void;
117
+ } | null>;
118
+ declare const unstable_SurfaceProvider: ({ accept, children, executeTool, reject, renderSuggestionValue, ...props }: SurfaceContextValue & {
119
+ children?: ReactNode;
120
+ }) => react.FunctionComponentElement<react.ProviderProps<SurfaceContextValue | null>>;
121
+ declare const unstable_useSurfaceContext: typeof useSurfaceContext;
112
122
 
113
123
  declare const theme: MapLeafNodes<{
114
124
  readonly borderRadius: {
@@ -498,5 +508,5 @@ declare const tokens: {
498
508
  };
499
509
  };
500
510
 
501
- export { AxiomAuthContext, AxiomVersionContext, ModalProvider, ToastProviderProvider, createToaster, theme, toaster, tokens, unstable_SurfaceProvider, unstable_useSurfaceContext, useModalContext, useToastProviderContext };
511
+ export { AxiomAuthContext, AxiomVersionContext, ModalProvider, ToastProviderProvider, createToaster, theme, toaster, tokens, unstable_SuggestionContext, unstable_SurfaceProvider, unstable_useSurfaceContext, useModalContext, useToastProviderContext };
502
512
  export type { MapLeafNodes };
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/optimizely-axiom/optiaxiom.git"
8
8
  },
9
9
  "type": "module",
10
- "version": "1.1.3",
10
+ "version": "1.1.5",
11
11
  "files": [
12
12
  "dist/**",
13
13
  "LICENSE"