@instockng/storefront-ui 1.0.20 → 1.0.21

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 (95) hide show
  1. package/dist/components/ui/modal.d.ts +1 -1
  2. package/dist/components/ui/modal.d.ts.map +1 -1
  3. package/dist/index134.mjs +1 -1
  4. package/dist/index136.mjs +1 -1
  5. package/dist/index137.mjs +2 -2
  6. package/dist/index141.mjs +2 -2
  7. package/dist/index144.mjs +4 -4
  8. package/dist/index145.mjs +5 -5
  9. package/dist/index150.mjs +1 -1
  10. package/dist/index151.mjs +1 -1
  11. package/dist/index152.mjs +1 -1
  12. package/dist/index153.mjs +1 -1
  13. package/dist/index154.mjs +1 -1
  14. package/dist/index156.mjs +1 -1
  15. package/dist/index157.mjs +1 -1
  16. package/dist/index159.mjs +2 -2
  17. package/dist/index160.mjs +1 -1
  18. package/dist/index165.mjs +2 -2
  19. package/dist/index167.mjs +1 -1
  20. package/dist/index169.mjs +2 -2
  21. package/dist/index170.mjs +5 -5
  22. package/dist/index173.mjs +1 -1
  23. package/dist/index176.mjs +1 -1
  24. package/dist/index179.mjs +1 -1
  25. package/dist/index180.mjs +1 -1
  26. package/dist/index184.mjs +1 -1
  27. package/dist/index186.mjs +1 -1
  28. package/dist/index190.mjs +1 -1
  29. package/dist/index192.mjs +1 -1
  30. package/dist/index201.mjs +2 -2
  31. package/dist/index205.mjs +31 -2
  32. package/dist/index206.mjs +10 -107
  33. package/dist/index207.mjs +4 -2
  34. package/dist/index208.mjs +4 -2
  35. package/dist/index209.mjs +13 -2
  36. package/dist/index210.mjs +7 -2
  37. package/dist/index211.mjs +12 -2
  38. package/dist/index212.mjs +5 -2
  39. package/dist/index213.mjs +33 -2
  40. package/dist/index214.mjs +31 -2
  41. package/dist/index215.mjs +28 -2
  42. package/dist/index216.mjs +58 -34
  43. package/dist/index217.mjs +2 -2
  44. package/dist/index218.mjs +2 -2
  45. package/dist/index219.mjs +2 -244
  46. package/dist/index220.mjs +2 -2
  47. package/dist/index221.mjs +2 -33
  48. package/dist/index222.mjs +2 -65
  49. package/dist/index223.mjs +2 -25
  50. package/dist/index224.mjs +2 -2
  51. package/dist/index225.mjs +108 -2
  52. package/dist/index226.mjs +2 -2
  53. package/dist/index227.mjs +2 -2
  54. package/dist/index228.mjs +2 -2
  55. package/dist/index229.mjs +37 -2
  56. package/dist/index231.mjs +244 -2
  57. package/dist/index232.mjs +2 -2
  58. package/dist/index233.mjs +33 -4
  59. package/dist/index234.mjs +64 -30
  60. package/dist/index235.mjs +24 -10
  61. package/dist/index236.mjs +2 -4
  62. package/dist/index237.mjs +2 -4
  63. package/dist/index238.mjs +2 -13
  64. package/dist/index239.mjs +2 -7
  65. package/dist/index240.mjs +2 -12
  66. package/dist/index241.mjs +2 -5
  67. package/dist/index242.mjs +2 -33
  68. package/dist/index243.mjs +2 -31
  69. package/dist/index244.mjs +2 -28
  70. package/dist/index245.mjs +4 -61
  71. package/dist/index248.mjs +2 -2
  72. package/dist/index249.mjs +18 -2
  73. package/dist/index250.mjs +42 -13
  74. package/dist/index251.mjs +2 -47
  75. package/dist/index252.mjs +2 -2
  76. package/dist/index257.mjs +2 -1
  77. package/dist/index258.mjs +2 -3
  78. package/dist/index259.mjs +2 -2
  79. package/dist/index260.mjs +17 -2
  80. package/dist/index261.mjs +11 -15
  81. package/dist/index262.mjs +6 -13
  82. package/dist/index263.mjs +30 -6
  83. package/dist/index264.mjs +2 -30
  84. package/dist/index37.mjs +72 -52
  85. package/dist/index38.mjs +1 -1
  86. package/dist/index4.mjs +48 -44
  87. package/dist/index42.mjs +1 -1
  88. package/dist/index60.mjs +20 -21
  89. package/dist/index61.mjs +24 -2
  90. package/dist/index63.mjs +2 -23
  91. package/dist/index66.mjs +1 -1
  92. package/dist/providers/MetaPixelProvider.d.ts.map +1 -1
  93. package/package.json +10 -11
  94. package/src/components/ui/modal.tsx +1 -1
  95. package/src/providers/MetaPixelProvider.tsx +23 -15
package/dist/index4.mjs CHANGED
@@ -1,88 +1,92 @@
1
1
  'use client';
2
2
  import { jsx as m } from "react/jsx-runtime";
3
- import { createContext as x, useContext as g, useState as w, useEffect as _ } from "react";
4
- import l from "./index37.mjs";
5
- const d = x(null);
6
- function z({ children: r, pixelId: c, debug: f }) {
7
- const [a, P] = w(!1), p = typeof process < "u" && process.env.NODE_ENV === "development", i = f ?? p;
3
+ import { createContext as w, useContext as h, useState as d, useEffect as _ } from "react";
4
+ const P = w(null);
5
+ function b({ children: c, pixelId: r, debug: f }) {
6
+ const [s, p] = d(!1), [a, x] = d(null), k = typeof process < "u" && process.env.NODE_ENV === "development", o = f ?? k;
8
7
  _(() => {
9
- if (typeof window > "u") return;
10
- if (!c) {
11
- i && console.log("[Meta Pixel] No pixel ID provided, tracking disabled");
12
- return;
8
+ if (!(typeof window > "u")) {
9
+ if (!r) {
10
+ o && console.log("[Meta Pixel] No pixel ID provided, tracking disabled");
11
+ return;
12
+ }
13
+ import("./index37.mjs").then((e) => e.f).then((e) => {
14
+ const t = e.default, i = {
15
+ autoConfig: !0,
16
+ debug: o
17
+ };
18
+ t.init(r, void 0, i), x(t), p(!0), o && console.log("[Meta Pixel] Initialized with ID:", r);
19
+ }).catch((e) => {
20
+ console.error("[Meta Pixel] Failed to load react-facebook-pixel:", e);
21
+ });
13
22
  }
14
- const e = {
15
- autoConfig: !0,
16
- debug: i
17
- };
18
- l.init(c, void 0, e), P(!0), i && console.log("[Meta Pixel] Initialized with ID:", c);
19
- }, [c, i]);
20
- const o = (e, t) => {
21
- if (!a) {
22
- i && console.log("[Meta Pixel] Track (not initialized):", e, t);
23
+ }, [r, o]);
24
+ const n = (e, t) => {
25
+ if (!s || !a) {
26
+ o && console.log("[Meta Pixel] Track (not initialized):", e, t);
23
27
  return;
24
28
  }
25
- l.track(e, t), i && console.log("[Meta Pixel] Track:", e, t);
26
- }, k = {
27
- track: o,
29
+ a.track(e, t), o && console.log("[Meta Pixel] Track:", e, t);
30
+ }, g = {
31
+ track: n,
28
32
  trackPageView: () => {
29
- if (!a) {
30
- i && console.log("[Meta Pixel] PageView (not initialized)");
33
+ if (!s || !a) {
34
+ o && console.log("[Meta Pixel] PageView (not initialized)");
31
35
  return;
32
36
  }
33
- l.pageView(), i && console.log("[Meta Pixel] PageView");
37
+ a.pageView(), o && console.log("[Meta Pixel] PageView");
34
38
  },
35
- trackProductView: (e, t, n) => {
36
- o("ViewContent", {
39
+ trackProductView: (e, t, i) => {
40
+ n("ViewContent", {
37
41
  content_ids: [e],
38
42
  content_name: t,
39
43
  content_type: "product",
40
- value: n,
44
+ value: i,
41
45
  currency: "NGN"
42
46
  });
43
47
  },
44
- trackAddToCart: (e, t, n, s) => {
45
- o("AddToCart", {
48
+ trackAddToCart: (e, t, i, l) => {
49
+ n("AddToCart", {
46
50
  content_ids: [e],
47
51
  content_name: t,
48
52
  content_type: "product",
49
- value: n,
53
+ value: i,
50
54
  currency: "NGN",
51
- num_items: s
55
+ num_items: l
52
56
  });
53
57
  },
54
58
  trackInitiateCheckout: (e, t) => {
55
- o("InitiateCheckout", {
59
+ n("InitiateCheckout", {
56
60
  value: e,
57
61
  currency: "NGN",
58
62
  num_items: t
59
63
  });
60
64
  },
61
- trackPurchase: (e, t, n, s) => {
62
- o("Purchase", {
65
+ trackPurchase: (e, t, i, l) => {
66
+ n("Purchase", {
63
67
  value: e,
64
68
  currency: t,
65
69
  content_type: "product",
66
- contents: s.map((u) => ({
70
+ contents: l.map((u) => ({
67
71
  id: u.id,
68
72
  // SKU
69
73
  quantity: u.quantity,
70
74
  item_price: u.item_price
71
75
  })),
72
- order_id: n
76
+ order_id: i
73
77
  });
74
78
  },
75
- isInitialized: a
79
+ isInitialized: s
76
80
  };
77
- return /* @__PURE__ */ m(d.Provider, { value: k, children: r });
81
+ return /* @__PURE__ */ m(P.Provider, { value: g, children: c });
78
82
  }
79
- function D() {
80
- const r = g(d);
81
- if (!r)
83
+ function z() {
84
+ const c = h(P);
85
+ if (!c)
82
86
  throw new Error("useMetaPixel must be used within MetaPixelProvider");
83
- return r;
87
+ return c;
84
88
  }
85
89
  export {
86
- z as MetaPixelProvider,
87
- D as useMetaPixel
90
+ b as MetaPixelProvider,
91
+ z as useMetaPixel
88
92
  };
package/dist/index42.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as l from "react";
3
- import { composeRefs as m } from "./index63.mjs";
3
+ import { composeRefs as m } from "./index60.mjs";
4
4
  import { jsx as u } from "react/jsx-runtime";
5
5
  // @__NO_SIDE_EFFECTS__
6
6
  function y(e) {
package/dist/index60.mjs CHANGED
@@ -1,27 +1,26 @@
1
1
  'use client';
2
- function n(e) {
3
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
2
+ import "react";
3
+ function i(n, o) {
4
+ if (typeof n == "function")
5
+ return n(o);
6
+ n != null && (n.current = o);
4
7
  }
5
- function c(e) {
6
- if (e.__esModule) return e;
7
- var o = e.default;
8
- if (typeof o == "function") {
9
- var t = function r() {
10
- return this instanceof r ? Reflect.construct(o, arguments, this.constructor) : o.apply(this, arguments);
11
- };
12
- t.prototype = o.prototype;
13
- } else t = {};
14
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
15
- var u = Object.getOwnPropertyDescriptor(e, r);
16
- Object.defineProperty(t, r, u.get ? u : {
17
- enumerable: !0,
18
- get: function() {
19
- return e[r];
20
- }
8
+ function f(...n) {
9
+ return (o) => {
10
+ let u = !1;
11
+ const c = n.map((t) => {
12
+ const e = i(t, o);
13
+ return !u && typeof e == "function" && (u = !0), e;
21
14
  });
22
- }), t;
15
+ if (u)
16
+ return () => {
17
+ for (let t = 0; t < c.length; t++) {
18
+ const e = c[t];
19
+ typeof e == "function" ? e() : i(n[t], null);
20
+ }
21
+ };
22
+ };
23
23
  }
24
24
  export {
25
- c as getAugmentedNamespace,
26
- n as getDefaultExportFromCjs
25
+ f as composeRefs
27
26
  };
package/dist/index61.mjs CHANGED
@@ -1,5 +1,27 @@
1
1
  'use client';
2
- var e = { exports: {} };
2
+ function n(e) {
3
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
+ }
5
+ function c(e) {
6
+ if (e.__esModule) return e;
7
+ var o = e.default;
8
+ if (typeof o == "function") {
9
+ var t = function r() {
10
+ return this instanceof r ? Reflect.construct(o, arguments, this.constructor) : o.apply(this, arguments);
11
+ };
12
+ t.prototype = o.prototype;
13
+ } else t = {};
14
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
15
+ var u = Object.getOwnPropertyDescriptor(e, r);
16
+ Object.defineProperty(t, r, u.get ? u : {
17
+ enumerable: !0,
18
+ get: function() {
19
+ return e[r];
20
+ }
21
+ });
22
+ }), t;
23
+ }
3
24
  export {
4
- e as __module
25
+ c as getAugmentedNamespace,
26
+ n as getDefaultExportFromCjs
5
27
  };
package/dist/index63.mjs CHANGED
@@ -1,26 +1,5 @@
1
1
  'use client';
2
- import "react";
3
- function i(n, o) {
4
- if (typeof n == "function")
5
- return n(o);
6
- n != null && (n.current = o);
7
- }
8
- function f(...n) {
9
- return (o) => {
10
- let u = !1;
11
- const c = n.map((t) => {
12
- const e = i(t, o);
13
- return !u && typeof e == "function" && (u = !0), e;
14
- });
15
- if (u)
16
- return () => {
17
- for (let t = 0; t < c.length; t++) {
18
- const e = c[t];
19
- typeof e == "function" ? e() : i(n[t], null);
20
- }
21
- };
22
- };
23
- }
2
+ var e = { exports: {} };
24
3
  export {
25
- f as composeRefs
4
+ e as __module
26
5
  };
package/dist/index66.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { getDefaultExportFromCjs as d } from "./index60.mjs";
2
+ import { getDefaultExportFromCjs as d } from "./index61.mjs";
3
3
  import { __module as v } from "./index94.mjs";
4
4
  v.exports = function(n) {
5
5
  return g(m(n), n);
@@ -1 +1 @@
1
- {"version":3,"file":"MetaPixelProvider.d.ts","sourceRoot":"","sources":["../../src/providers/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AAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,sBAAsB,2CA+HrF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,0BAQ3B;AAED,YAAY,EAAE,YAAY,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instockng/storefront-ui",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Pre-built UI components for OMS e-commerce sites",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,13 +20,6 @@
20
20
  "src",
21
21
  "README.md"
22
22
  ],
23
- "scripts": {
24
- "type-check": "tsc --noEmit",
25
- "build": "vite build && vite build --config vite.config.css.ts && tsc --project tsconfig.build.json",
26
- "prepublishOnly": "npm run build",
27
- "storybook": "storybook dev -p 6006",
28
- "build-storybook": "storybook build"
29
- },
30
23
  "repository": {
31
24
  "type": "git",
32
25
  "url": "git+https://github.com/ola-wale/oms.git",
@@ -65,8 +58,8 @@
65
58
  "@storybook/test": "^8.6.14",
66
59
  "@tailwindcss/postcss": "^4.1.14",
67
60
  "@tanstack/react-query": "^5.17.19",
68
- "@types/react": "npm:types-react@^19.0.0-rc.1",
69
- "@types/react-dom": "npm:types-react-dom@^19.0.0-rc.1",
61
+ "@types/react": "^19",
62
+ "@types/react-dom": "^19",
70
63
  "@vitejs/plugin-react": "^4.7.0",
71
64
  "autoprefixer": "^10.4.21",
72
65
  "lucide-react": "^0.536.0",
@@ -79,5 +72,11 @@
79
72
  "tailwindcss": "^4.1.14",
80
73
  "typescript": "^5.3.3",
81
74
  "vite": "^5.4.20"
75
+ },
76
+ "scripts": {
77
+ "type-check": "tsc --noEmit",
78
+ "build": "vite build && vite build --config vite.config.css.ts && tsc --project tsconfig.build.json || true",
79
+ "storybook": "storybook dev -p 6006",
80
+ "build-storybook": "storybook build"
82
81
  }
83
- }
82
+ }
@@ -46,7 +46,7 @@ export function Modal({
46
46
  size = 'md',
47
47
  closeOnOverlayClick = true,
48
48
  showCloseButton = true,
49
- }: ModalProps): JSX.Element | null {
49
+ }: ModalProps): React.ReactElement | null {
50
50
  const modalRef = useRef<HTMLDivElement>(null);
51
51
  const [isAnimating, setIsAnimating] = useState(false);
52
52
  const [shouldRender, setShouldRender] = useState(isOpen);
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
10
- import ReactPixel from 'react-facebook-pixel';
11
10
 
12
11
  interface PurchaseItem {
13
12
  id: string; // SKU
@@ -90,6 +89,7 @@ export interface MetaPixelProviderProps {
90
89
  */
91
90
  export function MetaPixelProvider({ children, pixelId, debug }: MetaPixelProviderProps) {
92
91
  const [isInitialized, setIsInitialized] = useState(false);
92
+ const [reactPixel, setReactPixel] = useState<any>(null);
93
93
  const isDevelopment = typeof process !== 'undefined' && process.env.NODE_ENV === 'development';
94
94
  const shouldDebug = debug ?? isDevelopment;
95
95
 
@@ -104,29 +104,37 @@ export function MetaPixelProvider({ children, pixelId, debug }: MetaPixelProvide
104
104
  return;
105
105
  }
106
106
 
107
- // Initialize Meta Pixel (client-side only)
108
- const options = {
109
- autoConfig: true,
110
- debug: shouldDebug,
111
- };
107
+ // Dynamically import react-facebook-pixel only on client
108
+ import('react-facebook-pixel').then((module) => {
109
+ const ReactPixel = module.default;
112
110
 
113
- ReactPixel.init(pixelId, undefined, options);
114
- setIsInitialized(true);
111
+ // Initialize Meta Pixel (client-side only)
112
+ const options = {
113
+ autoConfig: true,
114
+ debug: shouldDebug,
115
+ };
115
116
 
116
- if (shouldDebug) {
117
- console.log('[Meta Pixel] Initialized with ID:', pixelId);
118
- }
117
+ ReactPixel.init(pixelId, undefined, options);
118
+ setReactPixel(ReactPixel);
119
+ setIsInitialized(true);
120
+
121
+ if (shouldDebug) {
122
+ console.log('[Meta Pixel] Initialized with ID:', pixelId);
123
+ }
124
+ }).catch((error) => {
125
+ console.error('[Meta Pixel] Failed to load react-facebook-pixel:', error);
126
+ });
119
127
  }, [pixelId, shouldDebug]);
120
128
 
121
129
  const track = (event: string, data?: Record<string, unknown>) => {
122
- if (!isInitialized) {
130
+ if (!isInitialized || !reactPixel) {
123
131
  if (shouldDebug) {
124
132
  console.log('[Meta Pixel] Track (not initialized):', event, data);
125
133
  }
126
134
  return;
127
135
  }
128
136
 
129
- ReactPixel.track(event, data);
137
+ reactPixel.track(event, data);
130
138
 
131
139
  if (shouldDebug) {
132
140
  console.log('[Meta Pixel] Track:', event, data);
@@ -134,14 +142,14 @@ export function MetaPixelProvider({ children, pixelId, debug }: MetaPixelProvide
134
142
  };
135
143
 
136
144
  const trackPageView = () => {
137
- if (!isInitialized) {
145
+ if (!isInitialized || !reactPixel) {
138
146
  if (shouldDebug) {
139
147
  console.log('[Meta Pixel] PageView (not initialized)');
140
148
  }
141
149
  return;
142
150
  }
143
151
 
144
- ReactPixel.pageView();
152
+ reactPixel.pageView();
145
153
 
146
154
  if (shouldDebug) {
147
155
  console.log('[Meta Pixel] PageView');