@optiaxiom/globals 1.1.6 → 1.1.8
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 +21 -18
- package/dist/esm/surface-context.js +20 -17
- package/dist/esm/tokens/colors.js +1 -1
- package/dist/index.d.ts +10 -5
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -10,20 +10,22 @@ const [ModalProvider, useModalContext] = reactContext.createContext("@optiaxiom/
|
|
|
10
10
|
|
|
11
11
|
const SuggestionContext = react.createContext(null);
|
|
12
12
|
const SurfaceContext = react.createContext(null);
|
|
13
|
-
const SurfaceProvider = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
13
|
+
const SurfaceProvider = (props) => {
|
|
14
|
+
const {
|
|
15
|
+
accept,
|
|
16
|
+
children,
|
|
17
|
+
disabled,
|
|
18
|
+
executeTool,
|
|
19
|
+
reject,
|
|
20
|
+
renderSuggestionValue,
|
|
21
|
+
...rest
|
|
22
|
+
} = props;
|
|
24
23
|
const store = react.useContext(SuggestionContext);
|
|
24
|
+
const suggestion = !disabled && "suggestions" in rest ? rest.suggestions?.find(
|
|
25
|
+
(s) => ("/" + rest.path).endsWith("/" + s.surface) && (s.type === "message" || s.type === "value" && s.value !== rest.value)
|
|
26
|
+
) : void 0;
|
|
25
27
|
react.useEffect(() => {
|
|
26
|
-
if (!store || !suggestion || suggestion.type === "cards" ||
|
|
28
|
+
if (disabled || !store || !suggestion || suggestion.type === "cards" || rest.suggestionAlert?.registered || rest.suggestionPopover?.registered) {
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
return store.add(suggestion, {
|
|
@@ -33,23 +35,24 @@ const SurfaceProvider = ({
|
|
|
33
35
|
renderSuggestionValue
|
|
34
36
|
});
|
|
35
37
|
}, [
|
|
38
|
+
disabled,
|
|
36
39
|
accept,
|
|
37
40
|
executeTool,
|
|
38
|
-
|
|
39
|
-
props.suggestionPopover.registered,
|
|
41
|
+
rest.suggestionAlert?.registered,
|
|
40
42
|
reject,
|
|
41
43
|
renderSuggestionValue,
|
|
42
44
|
store,
|
|
43
|
-
suggestion
|
|
45
|
+
suggestion,
|
|
46
|
+
rest.suggestionPopover?.registered
|
|
44
47
|
]);
|
|
45
48
|
return react.createElement(SurfaceContext.Provider, {
|
|
46
49
|
children,
|
|
47
|
-
value: {
|
|
50
|
+
value: disabled ? null : {
|
|
48
51
|
accept,
|
|
49
52
|
executeTool,
|
|
50
53
|
reject,
|
|
51
54
|
renderSuggestionValue,
|
|
52
|
-
...
|
|
55
|
+
...rest
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
58
|
};
|
|
@@ -289,7 +292,7 @@ const colors = {
|
|
|
289
292
|
"fg.avatar.purple": ld(palette["purple.700"], palette["purple.100"]),
|
|
290
293
|
"fg.default": ld(palette["neutral.800"], palette["neutral.75"]),
|
|
291
294
|
"fg.default.inverse": ld(palette["neutral.00"], palette["neutral.800"]),
|
|
292
|
-
"fg.disabled": ld(palette["neutral.
|
|
295
|
+
"fg.disabled": ld(palette["neutral.500"], palette["neutral.50/32"]),
|
|
293
296
|
"fg.error": ld(palette["red.500"], palette["red.300"]),
|
|
294
297
|
"fg.error.hovered": ld(palette["red.600"], palette["red.600"]),
|
|
295
298
|
"fg.error.light": ld(palette["red.300"], palette["red.500"]),
|
|
@@ -3,20 +3,22 @@ import { createContext, useContext, useEffect, createElement } from 'react';
|
|
|
3
3
|
|
|
4
4
|
const SuggestionContext = createContext(null);
|
|
5
5
|
const SurfaceContext = createContext(null);
|
|
6
|
-
const SurfaceProvider = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
6
|
+
const SurfaceProvider = (props) => {
|
|
7
|
+
const {
|
|
8
|
+
accept,
|
|
9
|
+
children,
|
|
10
|
+
disabled,
|
|
11
|
+
executeTool,
|
|
12
|
+
reject,
|
|
13
|
+
renderSuggestionValue,
|
|
14
|
+
...rest
|
|
15
|
+
} = props;
|
|
17
16
|
const store = useContext(SuggestionContext);
|
|
17
|
+
const suggestion = !disabled && "suggestions" in rest ? rest.suggestions?.find(
|
|
18
|
+
(s) => ("/" + rest.path).endsWith("/" + s.surface) && (s.type === "message" || s.type === "value" && s.value !== rest.value)
|
|
19
|
+
) : void 0;
|
|
18
20
|
useEffect(() => {
|
|
19
|
-
if (!store || !suggestion || suggestion.type === "cards" ||
|
|
21
|
+
if (disabled || !store || !suggestion || suggestion.type === "cards" || rest.suggestionAlert?.registered || rest.suggestionPopover?.registered) {
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
return store.add(suggestion, {
|
|
@@ -26,23 +28,24 @@ const SurfaceProvider = ({
|
|
|
26
28
|
renderSuggestionValue
|
|
27
29
|
});
|
|
28
30
|
}, [
|
|
31
|
+
disabled,
|
|
29
32
|
accept,
|
|
30
33
|
executeTool,
|
|
31
|
-
|
|
32
|
-
props.suggestionPopover.registered,
|
|
34
|
+
rest.suggestionAlert?.registered,
|
|
33
35
|
reject,
|
|
34
36
|
renderSuggestionValue,
|
|
35
37
|
store,
|
|
36
|
-
suggestion
|
|
38
|
+
suggestion,
|
|
39
|
+
rest.suggestionPopover?.registered
|
|
37
40
|
]);
|
|
38
41
|
return createElement(SurfaceContext.Provider, {
|
|
39
42
|
children,
|
|
40
|
-
value: {
|
|
43
|
+
value: disabled ? null : {
|
|
41
44
|
accept,
|
|
42
45
|
executeTool,
|
|
43
46
|
reject,
|
|
44
47
|
renderSuggestionValue,
|
|
45
|
-
...
|
|
48
|
+
...rest
|
|
46
49
|
}
|
|
47
50
|
});
|
|
48
51
|
};
|
|
@@ -136,7 +136,7 @@ const colors = {
|
|
|
136
136
|
"fg.avatar.purple": ld(palette["purple.700"], palette["purple.100"]),
|
|
137
137
|
"fg.default": ld(palette["neutral.800"], palette["neutral.75"]),
|
|
138
138
|
"fg.default.inverse": ld(palette["neutral.00"], palette["neutral.800"]),
|
|
139
|
-
"fg.disabled": ld(palette["neutral.
|
|
139
|
+
"fg.disabled": ld(palette["neutral.500"], palette["neutral.50/32"]),
|
|
140
140
|
"fg.error": ld(palette["red.500"], palette["red.300"]),
|
|
141
141
|
"fg.error.hovered": ld(palette["red.600"], palette["red.600"]),
|
|
142
142
|
"fg.error.light": ld(palette["red.300"], palette["red.500"]),
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ type Surface = {
|
|
|
38
38
|
/**
|
|
39
39
|
* The surface type.
|
|
40
40
|
*/
|
|
41
|
-
type: "action" | "cards" | "
|
|
41
|
+
type: "action" | "cards" | "dialog" | "group" | "page" | "product" | "property" | "resource" | "tab";
|
|
42
42
|
/**
|
|
43
43
|
* Optional value associated with this surface.
|
|
44
44
|
*/
|
|
@@ -78,6 +78,7 @@ type SurfaceInteraction = {
|
|
|
78
78
|
name: "blurred";
|
|
79
79
|
} | {
|
|
80
80
|
name: "changed";
|
|
81
|
+
previousValue?: unknown;
|
|
81
82
|
value: unknown;
|
|
82
83
|
} | {
|
|
83
84
|
name: "focused";
|
|
@@ -120,9 +121,13 @@ declare const unstable_SuggestionContext: react.Context<{
|
|
|
120
121
|
type: "message" | "value";
|
|
121
122
|
}>, surface: Pick<SurfaceContextValue<V>, "accept" | "executeTool" | "reject" | "renderSuggestionValue">) => () => void;
|
|
122
123
|
} | null>;
|
|
123
|
-
declare const unstable_SurfaceProvider: <V = unknown>(
|
|
124
|
+
declare const unstable_SurfaceProvider: <V = unknown>(props: (Partial<SurfaceContextValue<V>> & {
|
|
124
125
|
children?: ReactNode;
|
|
125
|
-
|
|
126
|
+
disabled: true;
|
|
127
|
+
}) | (SurfaceContextValue<V> & {
|
|
128
|
+
children?: ReactNode;
|
|
129
|
+
disabled?: false;
|
|
130
|
+
})) => react.FunctionComponentElement<react.ProviderProps<SurfaceContextValue<unknown> | null>>;
|
|
126
131
|
declare const unstable_useSurfaceContext: typeof useSurfaceContext;
|
|
127
132
|
|
|
128
133
|
declare const theme: MapLeafNodes<{
|
|
@@ -197,7 +202,7 @@ declare const theme: MapLeafNodes<{
|
|
|
197
202
|
readonly "fg.avatar.purple": "light-dark(#412470, #E5DCF4)";
|
|
198
203
|
readonly "fg.default": "light-dark(#2E3442, #F5F6FA)";
|
|
199
204
|
readonly "fg.default.inverse": "light-dark(#FFFFFF, #2E3442)";
|
|
200
|
-
readonly "fg.disabled": "light-dark(#
|
|
205
|
+
readonly "fg.disabled": "light-dark(#838DA4, #F9FAFC52)";
|
|
201
206
|
readonly "fg.error": "light-dark(#CC1616, #FC8B8B)";
|
|
202
207
|
readonly "fg.error.hovered": "light-dark(#B21313, #B21313)";
|
|
203
208
|
readonly "fg.error.light": "light-dark(#FC8B8B, #CC1616)";
|
|
@@ -416,7 +421,7 @@ declare const tokens: {
|
|
|
416
421
|
readonly "fg.avatar.purple": "light-dark(#412470, #E5DCF4)";
|
|
417
422
|
readonly "fg.default": "light-dark(#2E3442, #F5F6FA)";
|
|
418
423
|
readonly "fg.default.inverse": "light-dark(#FFFFFF, #2E3442)";
|
|
419
|
-
readonly "fg.disabled": "light-dark(#
|
|
424
|
+
readonly "fg.disabled": "light-dark(#838DA4, #F9FAFC52)";
|
|
420
425
|
readonly "fg.error": "light-dark(#CC1616, #FC8B8B)";
|
|
421
426
|
readonly "fg.error.hovered": "light-dark(#B21313, #B21313)";
|
|
422
427
|
readonly "fg.error.light": "light-dark(#FC8B8B, #CC1616)";
|