@applicaster/zapp-react-native-utils 16.0.0-alpha.8415209737 → 16.0.0-alpha.8525514228

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 (32) hide show
  1. package/actionsExecutor/ActionExecutor.ts +8 -10
  2. package/actionsExecutor/ActionExecutorContext.tsx +39 -325
  3. package/actionsExecutor/actions/appRestart.ts +24 -0
  4. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  5. package/actionsExecutor/actions/index.ts +28 -0
  6. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  7. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  8. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  9. package/actionsExecutor/actions/navigateToScreen.ts +123 -0
  10. package/actionsExecutor/actions/refreshComponent.ts +94 -0
  11. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  12. package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
  13. package/actionsExecutor/actions/sendCloudEvent.ts +88 -0
  14. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  15. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  16. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  17. package/actionsExecutor/actions/switchLayout.ts +40 -0
  18. package/actionsExecutor/types.ts +57 -0
  19. package/cellUtils/index.ts +3 -5
  20. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  21. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  22. package/colorUtils/index.ts +50 -0
  23. package/manifestUtils/_internals/index.js +6 -0
  24. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  25. package/manifestUtils/fieldUtils/index.js +125 -0
  26. package/manifestUtils/keys.js +1 -0
  27. package/manifestUtils/platformIsTV.js +1 -0
  28. package/package.json +2 -2
  29. package/reactHooks/actions/index.ts +51 -1
  30. package/reactHooks/feed/useInflatedUrl.ts +1 -0
  31. package/riverComponetsMeasurementProvider/index.tsx +5 -1
  32. package/uiActionsRegistrator/index.ts +203 -0
@@ -0,0 +1,123 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "../ActionExecutor";
3
+ import { ActionHandler, ActionExecutionContext } from "../types";
4
+ import { createLogger } from "../../logger";
5
+
6
+ const { log_info, log_error } = createLogger({
7
+ subsystem: "ActionExecutorContext",
8
+ category: "General",
9
+ });
10
+
11
+ /**
12
+ * Options for the navigateToScreen action.
13
+ */
14
+ export interface NavigateToScreenOptions {
15
+ /** The screen type to navigate to (from content types mapping) */
16
+ typeMapping: string;
17
+
18
+ /** Navigation action: push adds to history, replace replaces current screen */
19
+ navigationAction?: "push" | "replace";
20
+
21
+ /**
22
+ * Entry to navigate with. Can be:
23
+ * - "@{entry/}" to use the context entry
24
+ * - A ZappEntry object
25
+ * - undefined to navigate to screen without entry
26
+ */
27
+ entry?: "@{entry/}" | ZappEntry;
28
+ }
29
+
30
+ /**
31
+ * Creates a navigation action handler with the provided dependencies.
32
+ * This factory pattern allows the action to access navigation state at runtime.
33
+ *
34
+ * @param navigator - The app navigator for push/replace operations
35
+ * @param rivers - Map of screen IDs to river definitions
36
+ * @param contentTypes - Map of content type names to screen configurations
37
+ * @returns An action handler that performs screen navigation
38
+ */
39
+ export function createNavigateToScreenAction(
40
+ navigator: QuickBrickAppNavigator,
41
+ rivers: Record<string, ZappRiver>,
42
+ contentTypes: ZappContentTypes
43
+ ): ActionHandler<NavigateToScreenOptions> {
44
+ return async function navigateToScreenAction(
45
+ action,
46
+ context?: ActionExecutionContext
47
+ ): Promise<ActionResult> {
48
+ const screenType = action.options?.typeMapping;
49
+
50
+ if (!screenType) {
51
+ log_error("navigateToScreen: typeMapping option is missing");
52
+
53
+ return ActionResult.Error;
54
+ }
55
+
56
+ const navigationAction = action.options?.navigationAction;
57
+ const entrySource = action.options?.entry;
58
+
59
+ const entry = entrySource
60
+ ? entrySource === "@{entry/}"
61
+ ? context?.entry
62
+ : entrySource
63
+ : null;
64
+
65
+ if (entry) {
66
+ if (typeof entry !== "object") {
67
+ log_error(
68
+ `navigateToScreen: entry option is not an object, entry: ${entry}`
69
+ );
70
+
71
+ return ActionResult.Error;
72
+ }
73
+
74
+ log_info(
75
+ `navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
76
+ );
77
+
78
+ const overriddenEntry: ZappEntry = {
79
+ ...entry,
80
+ type: {
81
+ value: screenType,
82
+ },
83
+ };
84
+
85
+ if (navigationAction === "push") {
86
+ navigator.push(overriddenEntry);
87
+ } else {
88
+ // Use replaceTop for entries since replace() only accepts ZappRiver
89
+ navigator.replaceTop(overriddenEntry);
90
+ }
91
+
92
+ return ActionResult.Success;
93
+ }
94
+
95
+ const screenId = contentTypes?.[screenType]?.screen_id || null;
96
+
97
+ if (!screenId) {
98
+ log_error(
99
+ `navigateToScreen: can not resolve screen type mapping: ${screenType}`
100
+ );
101
+
102
+ return ActionResult.Error;
103
+ }
104
+
105
+ const river = rivers[screenId];
106
+
107
+ if (!river) {
108
+ log_error("navigateToScreen: can not resolve river");
109
+
110
+ return ActionResult.Error;
111
+ }
112
+
113
+ context?.callback?.({ success: false, error: null, abort: true });
114
+
115
+ if (navigationAction === "push") {
116
+ navigator.push(river);
117
+ } else {
118
+ navigator.replace(river);
119
+ }
120
+
121
+ return ActionResult.Success;
122
+ };
123
+ }
@@ -0,0 +1,94 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
3
+ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
4
+ import {
5
+ getInflatedDataSourceUrl,
6
+ getSearchContext,
7
+ } from "../../reactHooks/feed/useInflatedUrl";
8
+ import { ActionResult } from "../ActionExecutor";
9
+ import { ActionHandler, ActionExecutionContext } from "../types";
10
+ import { createLogger } from "../../logger";
11
+
12
+ const { log_info } = createLogger({
13
+ subsystem: "ActionExecutorContext",
14
+ category: "General",
15
+ });
16
+
17
+ /**
18
+ * Helper function to find the parent component in a component tree.
19
+ */
20
+ function findParentComponent(
21
+ childId: string,
22
+ parent: ZappRiver | ZappUIComponent
23
+ ): ZappRiver | ZappUIComponent | null {
24
+ for (const child of parent.ui_components) {
25
+ if (child.id === childId) return parent;
26
+
27
+ if (child.ui_components) {
28
+ const found = findParentComponent(childId, child);
29
+ if (found) return found;
30
+ }
31
+ }
32
+
33
+ return null;
34
+ }
35
+
36
+ /**
37
+ * Refreshes a component's data by reloading its data source.
38
+ * Supports URL inflation with context variables.
39
+ */
40
+ export const refreshComponentAction: ActionHandler = async (
41
+ _action,
42
+ context?: ActionExecutionContext
43
+ ): Promise<ActionResult> => {
44
+ const dispatch = appStore.getDispatch();
45
+
46
+ const parentComponent = findParentComponent(
47
+ context?.component?.id,
48
+ context?.screenData
49
+ );
50
+
51
+ const componentSource = context?.component?.data?.source;
52
+
53
+ const componentData = componentSource
54
+ ? context.component.data
55
+ : parentComponent?.data;
56
+
57
+ const source = componentData?.source;
58
+ const mapping = componentData?.mapping;
59
+
60
+ let dataSource = source;
61
+
62
+ if (source && mapping) {
63
+ dataSource =
64
+ getInflatedDataSourceUrl({
65
+ source,
66
+ contexts: {
67
+ entry: context?.screenEntry,
68
+ screen: context?.screenData,
69
+ search: getSearchContext(null, mapping),
70
+ },
71
+ mapping,
72
+ }) || source;
73
+ }
74
+
75
+ log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
76
+ source,
77
+ inflatedUrl: dataSource,
78
+ mapping,
79
+ entryContextId: context?.entryContext?.id,
80
+ entryId: context?.entry?.id,
81
+ });
82
+
83
+ // TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
84
+ // TODO: handle focused item removal
85
+ dispatch(
86
+ loadPipesData(dataSource, {
87
+ silentRefresh: false,
88
+ clearCache: true,
89
+ riverId: context?.screenData?.id,
90
+ })
91
+ );
92
+
93
+ return ActionResult.Success;
94
+ };
@@ -0,0 +1,35 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { screenSetVariable } from "../ScreenActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for screenSetVariable action.
8
+ */
9
+ export interface ScreenSetVariableOptions {
10
+ /** The key/namespace for storing the variable */
11
+ key: string;
12
+
13
+ /** Path to extract the value from entry */
14
+ selector?: string;
15
+ }
16
+
17
+ /**
18
+ * Sets a variable in screen state storage.
19
+ * The value is extracted from the entry using the selector option.
20
+ */
21
+ export const screenSetVariableAction: ActionHandler<
22
+ ScreenSetVariableOptions
23
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
24
+ const route = context?.screenRoute;
25
+ const screenStateStore = context?.screenStateStore;
26
+
27
+ await screenSetVariable(
28
+ route,
29
+ screenStateStore,
30
+ { entry: context?.entry, options: action.options },
31
+ action
32
+ );
33
+
34
+ return ActionResult.Success;
35
+ };
@@ -0,0 +1,38 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { screenToggleFlag } from "../ScreenActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for screenToggleFlag action.
8
+ */
9
+ export interface ScreenToggleFlagOptions {
10
+ /** The key/namespace for storing the flag */
11
+ key: string;
12
+
13
+ /** Path to extract the tag from entry (e.g., "extensions.tag") */
14
+ selector?: string;
15
+
16
+ /** Maximum number of items that can be selected */
17
+ max_items?: number;
18
+ }
19
+
20
+ /**
21
+ * Toggles a flag in screen state storage (adds or removes an item from a collection).
22
+ * Useful for screen-level multi-select functionality.
23
+ */
24
+ export const screenToggleFlagAction: ActionHandler<
25
+ ScreenToggleFlagOptions
26
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
27
+ const screenRoute = context?.screenRoute;
28
+ const screenStateStore = context?.screenStateStore;
29
+
30
+ await screenToggleFlag(
31
+ screenRoute,
32
+ screenStateStore,
33
+ { entry: context?.entry, options: action.options },
34
+ action
35
+ );
36
+
37
+ return ActionResult.Success;
38
+ };
@@ -0,0 +1,88 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { createCloudEvent, sendCloudEvent } from "../../cloudEventsUtils";
3
+ import {
4
+ EntryResolver,
5
+ resolveObjectValues,
6
+ } from "../../appUtils/contextKeysManager/contextResolver";
7
+ import { ActionResult } from "../ActionExecutor";
8
+ import { ActionHandler, ActionExecutionContext } from "../types";
9
+ import { createLogger } from "../../logger";
10
+
11
+ const { log_info, log_error } = createLogger({
12
+ subsystem: "ActionExecutorContext",
13
+ category: "General",
14
+ });
15
+
16
+ /**
17
+ * Options for the sendCloudEvent action.
18
+ */
19
+ export interface SendCloudEventOptions {
20
+ /** The cloud event type (defaults to "com.applicaster.selector.action.v1") */
21
+ type?: string;
22
+
23
+ /** The event data payload */
24
+ data?: Record<string, any>;
25
+
26
+ /** The event subject (defaults to entry.id) */
27
+ subject?: string;
28
+
29
+ /** The URL endpoint to send the event to */
30
+ url: string;
31
+
32
+ /** Whether to inflate data with context variables */
33
+ inflateData?: boolean;
34
+ }
35
+
36
+ /**
37
+ * Sends a cloud event to a remote endpoint.
38
+ * Supports data inflation using context variables from entry and screen.
39
+ */
40
+ export const sendCloudEventAction: ActionHandler<
41
+ SendCloudEventOptions
42
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
43
+ try {
44
+ const options = action.options as SendCloudEventOptions;
45
+
46
+ const entry = context?.entry || {};
47
+ const entryResolver = new EntryResolver(entry as ZappEntry);
48
+ const screenData = context?.screenStateStore?.getState?.()?.data || {};
49
+ const screenResolver = new EntryResolver(screenData as ZappEntry);
50
+
51
+ const data =
52
+ options?.data && options.inflateData
53
+ ? await resolveObjectValues(options.data, {
54
+ entry: entryResolver,
55
+ screen: screenResolver,
56
+ })
57
+ : options?.data || entry;
58
+
59
+ const cloudEvent = await createCloudEvent({
60
+ type: options.type || "com.applicaster.selector.action.v1",
61
+ data,
62
+ subject: options.subject || String((entry as ZappEntry)?.id || ""),
63
+ });
64
+
65
+ log_info("handleAction: sendCloudEvent event", { cloudEvent });
66
+
67
+ const { error, code } = await sendCloudEvent(cloudEvent, options.url);
68
+
69
+ if (error) {
70
+ log_error("sendCloudEvent: error sending cloud event", { error });
71
+
72
+ return ActionResult.Error;
73
+ }
74
+
75
+ if (code && code >= 200 && code < 300 && !error) {
76
+ log_info("sendCloudEvent: cloud event sent successfully");
77
+
78
+ return ActionResult.Success;
79
+ }
80
+ } catch (error) {
81
+ log_error("sendCloudEvent: error sending cloud event", {
82
+ action,
83
+ error,
84
+ });
85
+ }
86
+
87
+ return ActionResult.Error;
88
+ };
@@ -0,0 +1,19 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
3
+ import { batchRemoveFromStorage } from "../../zappFrameworkUtils/localStorageHelper";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { StorageRemoveOptions } from "./localStorageRemove";
7
+
8
+ /**
9
+ * Removes values from session storage organized by namespaces.
10
+ */
11
+ export const sessionStorageRemoveAction: ActionHandler<
12
+ StorageRemoveOptions
13
+ > = async (action): Promise<ActionResult> => {
14
+ const namespaces = action.options.content;
15
+ await batchRemoveFromStorage(namespaces, sessionStorage);
16
+ // TODO: Add support for ownershipKey and ownershipNamespace
17
+
18
+ return ActionResult.Success;
19
+ };
@@ -0,0 +1,20 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
3
+ import { batchSave } from "../../zappFrameworkUtils/localStorageHelper";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { StorageSetOptions } from "./localStorageSet";
7
+
8
+ /**
9
+ * Saves values to session storage organized by namespaces.
10
+ * The values persist only for the current app session.
11
+ */
12
+ export const sessionStorageSetAction: ActionHandler<StorageSetOptions> = async (
13
+ action
14
+ ): Promise<ActionResult> => {
15
+ const namespaces = (action.options as StorageSetOptions).content;
16
+ await batchSave(namespaces, sessionStorage);
17
+ // TODO: Add support for ownershipKey and ownershipNamespace
18
+
19
+ return ActionResult.Success;
20
+ };
@@ -0,0 +1,15 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { sessionStorageToggleFlag } from "../StorageActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+ import { StorageToggleFlagOptions } from "./localStorageToggleFlag";
6
+
7
+ /**
8
+ * Toggles a flag in session storage (adds or removes an item from a collection).
9
+ * Values persist only for the current app session.
10
+ */
11
+ export const sessionStorageToggleFlagAction: ActionHandler<
12
+ StorageToggleFlagOptions
13
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
14
+ return await sessionStorageToggleFlag(context, action);
15
+ };
@@ -0,0 +1,40 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
+ import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
4
+ import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
5
+ import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
6
+ import { ActionResult } from "../ActionExecutor";
7
+ import { ActionHandler } from "../types";
8
+ import { createLogger } from "../../logger";
9
+
10
+ const { log_info } = createLogger({
11
+ subsystem: "ActionExecutorContext",
12
+ category: "General",
13
+ });
14
+
15
+ /**
16
+ * Options for the switchLayout action.
17
+ */
18
+ export interface SwitchLayoutOptions {
19
+ /** The ID of the layout to switch to */
20
+ layoutId: string;
21
+ }
22
+
23
+ /**
24
+ * Switches the active layout and triggers an app reload.
25
+ * Saves the new layout ID to local storage before reloading.
26
+ */
27
+ export const switchLayoutAction: ActionHandler<SwitchLayoutOptions> = async (
28
+ action
29
+ ): Promise<ActionResult> => {
30
+ log_info("handleAction: switchLayout event");
31
+
32
+ await localStorage.setItem(
33
+ ACTIVE_LAYOUT_ID_STORAGE_KEY,
34
+ action.options.layoutId
35
+ );
36
+
37
+ QuickBrickManager.sendQuickBrickEvent(QUICK_BRICK_EVENTS.FORCE_APP_RELOAD);
38
+
39
+ return ActionResult.Success;
40
+ };
@@ -0,0 +1,57 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "./ActionExecutor";
3
+ import { useScreenStateStore } from "../reactHooks/navigation/useScreenStateStore";
4
+
5
+ /**
6
+ * Base context object passed to action handlers during execution.
7
+ * Contains references to the current entry, screen, and other execution state.
8
+ */
9
+ export interface ActionExecutionContext {
10
+ /** The entry associated with this action (e.g., the item that was tapped) */
11
+ entry?: ZappEntry;
12
+
13
+ /** The current screen/river data */
14
+ screenData?: ZappRiver;
15
+
16
+ /** The entry that defines the screen (if screen was opened from an entry) */
17
+ screenEntry?: ZappEntry;
18
+
19
+ /** The UI component that triggered the action */
20
+ component?: ZappUIComponent;
21
+
22
+ /** The route identifier for the current screen */
23
+ screenRoute?: string;
24
+
25
+ /** The screen state store for managing screen-level state (Zustand store) */
26
+ screenStateStore?: ReturnType<typeof useScreenStateStore>;
27
+
28
+ /** Context entry for additional data */
29
+ entryContext?: ZappEntry;
30
+
31
+ /** Callback function for action completion */
32
+ callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
33
+
34
+ screenState: Record<any, any>;
35
+ }
36
+
37
+ /**
38
+ * Type for action handler functions.
39
+ * Handlers receive the action (which may have typed options) and execution context.
40
+ *
41
+ * @template _TOptions - Optional type hint for the action's options object (for documentation/intellisense)
42
+ * @param action - The action to execute
43
+ * @param context - The execution context
44
+ * @returns A promise that resolves to the action result
45
+ */
46
+ export type ActionHandler<_TOptions = any> = (
47
+ action: ActionType,
48
+ context?: ActionExecutionContext
49
+ ) => Promise<ActionResult>;
50
+
51
+ /**
52
+ * Factory function that creates an action handler.
53
+ * Used for actions that need to capture dependencies at registration time.
54
+ */
55
+ export type ActionHandlerFactory<_TOptions = any> = (
56
+ ...dependencies: any[]
57
+ ) => ActionHandler<_TOptions>;
@@ -1,7 +1,7 @@
1
1
  import * as R from "ramda";
2
2
  import { dayjs } from "../dateUtils";
3
- import validateColor from "validate-color";
4
3
 
4
+ import { isValidColor } from "@applicaster/zapp-react-native-utils/colorUtils";
5
5
  import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
6
6
  import {
7
7
  capitalize,
@@ -468,15 +468,13 @@ export const getColorFromData = ({
468
468
  data,
469
469
  valueFromLayout,
470
470
  }: GetColorFromData): string => {
471
- // Temporary hack to fix color validation when alpha is floating point number
472
- // https://github.com/dreamyguy/validate-color/issues/44
473
- if (validateColor(valueFromLayout.replace(".00", ""))) {
471
+ if (isValidColor(valueFromLayout)) {
474
472
  return valueFromLayout;
475
473
  }
476
474
 
477
475
  const pathValue = R.path(valueFromLayout.split("."), data);
478
476
 
479
- if (pathValue && validateColor(pathValue)) {
477
+ if (pathValue && isValidColor(pathValue)) {
480
478
  return pathValue;
481
479
  }
482
480
 
@@ -0,0 +1,76 @@
1
+ import { isTransparentColor } from "..";
2
+
3
+ describe("isTransparentColor", () => {
4
+ it("returns true for transparent keyword and rgba colors with zero alpha", () => {
5
+ const transparentColors = [
6
+ "transparent",
7
+ "rgba(0,0,0,0)",
8
+ "rgba(255, 255, 255, 0)",
9
+ "rgba(0,0,0,0.0)",
10
+ "rgba(0,0,0,0.00)",
11
+ "rgba(0,0,0, 0)",
12
+ "hsla(0,0%,0%,0)",
13
+ ];
14
+
15
+ expect.assertions(transparentColors.length);
16
+
17
+ transparentColors.forEach((color) => {
18
+ expect(isTransparentColor(color)).toBe(true);
19
+ });
20
+ });
21
+
22
+ it("returns false for valid colors that are not fully transparent", () => {
23
+ const nonTransparentColors = [
24
+ "red",
25
+ "#fff",
26
+ "#ffffff",
27
+ "rgb(0,0,0)",
28
+ "rgba(0,0,0)",
29
+ "rgba(0,0,0,0.5)",
30
+ "rgba(255, 255, 255, 0.3)",
31
+ "rgba(255, 255, 255, 1.0)",
32
+ "rgba(239,239,239,1.0)",
33
+ "currentColor",
34
+ "inherit",
35
+ "#00000000",
36
+ "#fff0",
37
+ ];
38
+
39
+ expect.assertions(nonTransparentColors.length);
40
+
41
+ nonTransparentColors.forEach((color) => {
42
+ expect(isTransparentColor(color)).toBe(false);
43
+ });
44
+ });
45
+
46
+ it("returns false for case variants of the transparent keyword", () => {
47
+ expect(isTransparentColor("Transparent")).toBe(false);
48
+ expect(isTransparentColor("TRANSPARENT")).toBe(false);
49
+ });
50
+
51
+ it("returns false for invalid color strings", () => {
52
+ const invalidColors = [
53
+ "invalid",
54
+ "",
55
+ "#gggggg",
56
+ "#fff.00",
57
+ "unset",
58
+ " rgba(0,0,0,0) ",
59
+ "transparent ",
60
+ ];
61
+
62
+ expect.assertions(invalidColors.length);
63
+
64
+ invalidColors.forEach((color) => {
65
+ expect(isTransparentColor(color)).toBe(false);
66
+ });
67
+ });
68
+
69
+ it("returns false for nullish and non-string values", () => {
70
+ expect(isTransparentColor(undefined)).toBe(false);
71
+ expect(isTransparentColor(null)).toBe(false);
72
+ expect(isTransparentColor(123)).toBe(false);
73
+ expect(isTransparentColor({})).toBe(false);
74
+ expect(isTransparentColor([])).toBe(false);
75
+ });
76
+ });