@birimengo/calculator 1.0.2 → 1.0.4

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/index.es.js CHANGED
@@ -1,149 +1,148 @@
1
- import le, { useState as O, useCallback as b, memo as U, useEffect as ce } from "react";
2
- import { Calculator as ie, Clock as ue, Zap as me, PlusCircle as de, MinusCircle as fe, RotateCw as pe, Trash2 as he, Percent as xe, RotateCcw as be, Delete as Ee, Divide as ye, X as je, Minus as ge, Plus as Ne, Equal as _e } from "lucide-react";
3
- var A = { exports: {} }, T = {};
4
- var H;
5
- function Re() {
6
- if (H) return T;
7
- H = 1;
8
- var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function c(i, l, n) {
10
- var p = null;
11
- if (n !== void 0 && (p = "" + n), l.key !== void 0 && (p = "" + l.key), "key" in l) {
12
- n = {};
13
- for (var y in l)
14
- y !== "key" && (n[y] = l[y]);
15
- } else n = l;
16
- return l = n.ref, {
1
+ import le, { memo as B, useState as R, useEffect as ce, useCallback as E } from "react";
2
+ var L = { exports: {} }, V = {};
3
+ var ee;
4
+ function ie() {
5
+ if (ee) return V;
6
+ ee = 1;
7
+ var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function c(u, s, o) {
9
+ var f = null;
10
+ if (o !== void 0 && (f = "" + o), s.key !== void 0 && (f = "" + s.key), "key" in s) {
11
+ o = {};
12
+ for (var g in s)
13
+ g !== "key" && (o[g] = s[g]);
14
+ } else o = s;
15
+ return s = o.ref, {
17
16
  $$typeof: r,
18
- type: i,
19
- key: p,
20
- ref: l !== void 0 ? l : null,
21
- props: n
17
+ type: u,
18
+ key: f,
19
+ ref: s !== void 0 ? s : null,
20
+ props: o
22
21
  };
23
22
  }
24
- return T.Fragment = a, T.jsx = c, T.jsxs = c, T;
23
+ return V.Fragment = t, V.jsx = c, V.jsxs = c, V;
25
24
  }
26
- var S = {};
27
- var Q;
28
- function ke() {
29
- return Q || (Q = 1, process.env.NODE_ENV !== "production" && (function() {
25
+ var I = {};
26
+ var re;
27
+ function ue() {
28
+ return re || (re = 1, process.env.NODE_ENV !== "production" && (function() {
30
29
  function r(e) {
31
30
  if (e == null) return null;
32
31
  if (typeof e == "function")
33
- return e.$$typeof === se ? null : e.displayName || e.name || null;
32
+ return e.$$typeof === j ? null : e.displayName || e.name || null;
34
33
  if (typeof e == "string") return e;
35
34
  switch (e) {
36
- case v:
35
+ case w:
37
36
  return "Fragment";
38
- case $:
37
+ case M:
39
38
  return "Profiler";
40
- case D:
39
+ case F:
41
40
  return "StrictMode";
42
41
  case x:
43
42
  return "Suspense";
44
- case C:
43
+ case N:
45
44
  return "SuspenseList";
46
- case ae:
45
+ case k:
47
46
  return "Activity";
48
47
  }
49
48
  if (typeof e == "object")
50
49
  switch (typeof e.tag == "number" && console.error(
51
50
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
51
  ), e.$$typeof) {
53
- case M:
52
+ case $:
54
53
  return "Portal";
55
54
  case Y:
56
55
  return e.displayName || "Context";
57
- case F:
56
+ case D:
58
57
  return (e._context.displayName || "Context") + ".Consumer";
59
- case o:
60
- var s = e.render;
61
- return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case te:
63
- return s = e.displayName || null, s !== null ? s : r(e.type) || "Memo";
64
- case z:
65
- s = e._payload, e = e._init;
58
+ case l:
59
+ var a = e.render;
60
+ return e = e.displayName, e || (e = a.displayName || a.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case i:
62
+ return a = e.displayName || null, a !== null ? a : r(e.type) || "Memo";
63
+ case p:
64
+ a = e._payload, e = e._init;
66
65
  try {
67
- return r(e(s));
66
+ return r(e(a));
68
67
  } catch {
69
68
  }
70
69
  }
71
70
  return null;
72
71
  }
73
- function a(e) {
72
+ function t(e) {
74
73
  return "" + e;
75
74
  }
76
75
  function c(e) {
77
76
  try {
78
- a(e);
79
- var s = !1;
77
+ t(e);
78
+ var a = !1;
80
79
  } catch {
81
- s = !0;
80
+ a = !0;
82
81
  }
83
- if (s) {
84
- s = console;
85
- var u = s.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return u.call(
87
- s,
82
+ if (a) {
83
+ a = console;
84
+ var m = a.error, b = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return m.call(
86
+ a,
88
87
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- d
90
- ), a(e);
88
+ b
89
+ ), t(e);
91
90
  }
92
91
  }
93
- function i(e) {
94
- if (e === v) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === z)
92
+ function u(e) {
93
+ if (e === w) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === p)
96
95
  return "<...>";
97
96
  try {
98
- var s = r(e);
99
- return s ? "<" + s + ">" : "<...>";
97
+ var a = r(e);
98
+ return a ? "<" + a + ">" : "<...>";
100
99
  } catch {
101
100
  return "<...>";
102
101
  }
103
102
  }
104
- function l() {
105
- var e = I.A;
103
+ function s() {
104
+ var e = W.A;
106
105
  return e === null ? null : e.getOwner();
107
106
  }
108
- function n() {
107
+ function o() {
109
108
  return Error("react-stack-top-frame");
110
109
  }
111
- function p(e) {
112
- if (J.call(e, "key")) {
113
- var s = Object.getOwnPropertyDescriptor(e, "key").get;
114
- if (s && s.isReactWarning) return !1;
110
+ function f(e) {
111
+ if (G.call(e, "key")) {
112
+ var a = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (a && a.isReactWarning) return !1;
115
114
  }
116
115
  return e.key !== void 0;
117
116
  }
118
- function y(e, s) {
119
- function u() {
120
- V || (V = !0, console.error(
117
+ function g(e, a) {
118
+ function m() {
119
+ X || (X = !0, console.error(
121
120
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
- s
121
+ a
123
122
  ));
124
123
  }
125
- u.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: u,
124
+ m.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: m,
127
126
  configurable: !0
128
127
  });
129
128
  }
130
- function k() {
129
+ function C() {
131
130
  var e = r(this.type);
132
- return B[e] || (B[e] = !0, console.error(
131
+ return H[e] || (H[e] = !0, console.error(
133
132
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
133
  )), e = this.props.ref, e !== void 0 ? e : null;
135
134
  }
136
- function w(e, s, u, d, P, L) {
137
- var f = u.ref;
135
+ function y(e, a, m, b, q, J) {
136
+ var h = m.ref;
138
137
  return e = {
139
- $$typeof: h,
138
+ $$typeof: P,
140
139
  type: e,
141
- key: s,
142
- props: u,
143
- _owner: d
144
- }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", {
140
+ key: a,
141
+ props: m,
142
+ _owner: b
143
+ }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(e, "ref", {
145
144
  enumerable: !1,
146
- get: k
145
+ get: C
147
146
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
147
  configurable: !1,
149
148
  enumerable: !1,
@@ -158,119 +157,313 @@ function ke() {
158
157
  configurable: !1,
159
158
  enumerable: !1,
160
159
  writable: !0,
161
- value: P
160
+ value: q
162
161
  }), Object.defineProperty(e, "_debugTask", {
163
162
  configurable: !1,
164
163
  enumerable: !1,
165
164
  writable: !0,
166
- value: L
165
+ value: J
167
166
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
167
  }
169
- function g(e, s, u, d, P, L) {
170
- var f = s.children;
171
- if (f !== void 0)
172
- if (d)
173
- if (ne(f)) {
174
- for (d = 0; d < f.length; d++)
175
- N(f[d]);
176
- Object.freeze && Object.freeze(f);
168
+ function T(e, a, m, b, q, J) {
169
+ var h = a.children;
170
+ if (h !== void 0)
171
+ if (b)
172
+ if (se(h)) {
173
+ for (b = 0; b < h.length; b++)
174
+ v(h[b]);
175
+ Object.freeze && Object.freeze(h);
177
176
  } else
178
177
  console.error(
179
178
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
179
  );
181
- else N(f);
182
- if (J.call(s, "key")) {
183
- f = r(e);
184
- var R = Object.keys(s).filter(function(oe) {
180
+ else v(h);
181
+ if (G.call(a, "key")) {
182
+ h = r(e);
183
+ var A = Object.keys(a).filter(function(oe) {
185
184
  return oe !== "key";
186
185
  });
187
- d = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", Z[f + d] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
186
+ b = 0 < A.length ? "{key: someKey, " + A.join(": ..., ") + ": ...}" : "{key: someKey}", K[h + b] || (A = 0 < A.length ? "{" + A.join(": ..., ") + ": ...}" : "{}", console.error(
188
187
  `A props object containing a "key" prop is being spread into JSX:
189
188
  let props = %s;
190
189
  <%s {...props} />
191
190
  React keys must be passed directly to JSX without using spread:
192
191
  let props = %s;
193
192
  <%s key={someKey} {...props} />`,
194
- d,
195
- f,
196
- R,
197
- f
198
- ), Z[f + d] = !0);
193
+ b,
194
+ h,
195
+ A,
196
+ h
197
+ ), K[h + b] = !0);
199
198
  }
200
- if (f = null, u !== void 0 && (c(u), f = "" + u), p(s) && (c(s.key), f = "" + s.key), "key" in s) {
201
- u = {};
202
- for (var W in s)
203
- W !== "key" && (u[W] = s[W]);
204
- } else u = s;
205
- return f && y(
206
- u,
199
+ if (h = null, m !== void 0 && (c(m), h = "" + m), f(a) && (c(a.key), h = "" + a.key), "key" in a) {
200
+ m = {};
201
+ for (var z in a)
202
+ z !== "key" && (m[z] = a[z]);
203
+ } else m = a;
204
+ return h && g(
205
+ m,
207
206
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), w(
207
+ ), y(
209
208
  e,
210
- f,
211
- u,
212
- l(),
213
- P,
214
- L
209
+ h,
210
+ m,
211
+ s(),
212
+ q,
213
+ J
215
214
  );
216
215
  }
217
- function N(e) {
218
- _(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === z && (e._payload.status === "fulfilled" ? _(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
216
+ function v(e) {
217
+ O(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === p && (e._payload.status === "fulfilled" ? O(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
218
  }
220
- function _(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === h;
219
+ function O(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === P;
222
221
  }
223
- var j = le, h = /* @__PURE__ */ Symbol.for("react.transitional.element"), M = /* @__PURE__ */ Symbol.for("react.portal"), v = /* @__PURE__ */ Symbol.for("react.fragment"), D = /* @__PURE__ */ Symbol.for("react.strict_mode"), $ = /* @__PURE__ */ Symbol.for("react.profiler"), F = /* @__PURE__ */ Symbol.for("react.consumer"), Y = /* @__PURE__ */ Symbol.for("react.context"), o = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), C = /* @__PURE__ */ Symbol.for("react.suspense_list"), te = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), ae = /* @__PURE__ */ Symbol.for("react.activity"), se = /* @__PURE__ */ Symbol.for("react.client.reference"), I = j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ne = Array.isArray, q = console.createTask ? console.createTask : function() {
222
+ var S = le, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), $ = /* @__PURE__ */ Symbol.for("react.portal"), w = /* @__PURE__ */ Symbol.for("react.fragment"), F = /* @__PURE__ */ Symbol.for("react.strict_mode"), M = /* @__PURE__ */ Symbol.for("react.profiler"), D = /* @__PURE__ */ Symbol.for("react.consumer"), Y = /* @__PURE__ */ Symbol.for("react.context"), l = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), N = /* @__PURE__ */ Symbol.for("react.suspense_list"), i = /* @__PURE__ */ Symbol.for("react.memo"), p = /* @__PURE__ */ Symbol.for("react.lazy"), k = /* @__PURE__ */ Symbol.for("react.activity"), j = /* @__PURE__ */ Symbol.for("react.client.reference"), W = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, se = Array.isArray, U = console.createTask ? console.createTask : function() {
224
223
  return null;
225
224
  };
226
- j = {
225
+ S = {
227
226
  react_stack_bottom_frame: function(e) {
228
227
  return e();
229
228
  }
230
229
  };
231
- var V, B = {}, G = j.react_stack_bottom_frame.bind(
232
- j,
233
- n
234
- )(), X = q(i(n)), Z = {};
235
- S.Fragment = v, S.jsx = function(e, s, u) {
236
- var d = 1e4 > I.recentlyCreatedOwnerStacks++;
237
- return g(
230
+ var X, H = {}, Q = S.react_stack_bottom_frame.bind(
231
+ S,
232
+ o
233
+ )(), Z = U(u(o)), K = {};
234
+ I.Fragment = w, I.jsx = function(e, a, m) {
235
+ var b = 1e4 > W.recentlyCreatedOwnerStacks++;
236
+ return T(
238
237
  e,
239
- s,
240
- u,
238
+ a,
239
+ m,
241
240
  !1,
242
- d ? Error("react-stack-top-frame") : G,
243
- d ? q(i(e)) : X
241
+ b ? Error("react-stack-top-frame") : Q,
242
+ b ? U(u(e)) : Z
244
243
  );
245
- }, S.jsxs = function(e, s, u) {
246
- var d = 1e4 > I.recentlyCreatedOwnerStacks++;
247
- return g(
244
+ }, I.jsxs = function(e, a, m) {
245
+ var b = 1e4 > W.recentlyCreatedOwnerStacks++;
246
+ return T(
248
247
  e,
249
- s,
250
- u,
248
+ a,
249
+ m,
251
250
  !0,
252
- d ? Error("react-stack-top-frame") : G,
253
- d ? q(i(e)) : X
251
+ b ? Error("react-stack-top-frame") : Q,
252
+ b ? U(u(e)) : Z
254
253
  );
255
254
  };
256
- })()), S;
255
+ })()), I;
257
256
  }
258
- var K;
259
- function we() {
260
- return K || (K = 1, process.env.NODE_ENV === "production" ? A.exports = Re() : A.exports = ke()), A.exports;
257
+ var te;
258
+ function de() {
259
+ return te || (te = 1, process.env.NODE_ENV === "production" ? L.exports = ie() : L.exports = ue()), L.exports;
261
260
  }
262
- var t = we();
263
- const E = {
261
+ var n = de();
262
+ const ne = B(({ value: r, memory: t, expression: c }) => /* @__PURE__ */ n.jsxs("div", { className: "border border-white/30 rounded-2xl p-6 bg-black/5", children: [
263
+ /* @__PURE__ */ n.jsx("div", { className: "text-right text-sm text-blue-600 dark:text-blue-400 font-mono mb-1 h-5 opacity-70", children: c }),
264
+ /* @__PURE__ */ n.jsx("div", { className: "text-right", children: /* @__PURE__ */ n.jsx("div", { className: "text-6xl font-light text-blue-600 dark:text-blue-400 font-mono tracking-tight", children: r }) }),
265
+ t !== 0 && /* @__PURE__ */ n.jsxs("div", { className: "absolute top-2 left-2 text-xs border border-white/30 rounded-full px-2 py-1 bg-black/5 text-blue-600 dark:text-blue-400 font-medium", children: [
266
+ "M=",
267
+ t
268
+ ] })
269
+ ] }));
270
+ ne.displayName = "Display";
271
+ const d = B(({
272
+ children: r,
273
+ onClick: t,
274
+ type: c = "number",
275
+ className: u = ""
276
+ }) => {
277
+ const s = "px-4 py-3 text-base rounded-lg font-semibold transition-all duration-200 active:scale-95 shadow-sm border border-white/30 hover:border-white/60", o = {
278
+ // Number buttons: blue text, subtle background
279
+ number: "bg-black/5 text-blue-600 dark:text-blue-400 hover:bg-black/10",
280
+ // Operator buttons: blue text, slightly darker background
281
+ operator: "bg-black/10 text-blue-600 dark:text-blue-400 hover:bg-black/20",
282
+ // Function buttons: blue text, subtle background
283
+ function: "bg-black/5 text-blue-600 dark:text-blue-400 hover:bg-black/10",
284
+ // Equals button: blue text, slightly darker
285
+ equals: "bg-black/10 text-blue-600 dark:text-blue-400 hover:bg-black/20",
286
+ // Memory buttons: blue text, subtle background
287
+ memory: "bg-black/5 text-blue-600 dark:text-blue-400 hover:bg-black/10 text-sm"
288
+ };
289
+ return /* @__PURE__ */ n.jsx(
290
+ "button",
291
+ {
292
+ onClick: t,
293
+ className: `${s} ${o[c]} ${u}`,
294
+ children: r
295
+ }
296
+ );
297
+ });
298
+ d.displayName = "Button";
299
+ const ae = B(({
300
+ onNumber: r,
301
+ onDecimal: t,
302
+ onOperator: c,
303
+ onEquals: u,
304
+ onClear: s,
305
+ onBackspace: o,
306
+ onPercentage: f,
307
+ onToggleSign: g,
308
+ onMemoryAdd: C,
309
+ onMemorySubtract: y,
310
+ onMemoryRecall: T,
311
+ onMemoryClear: v
312
+ }) => /* @__PURE__ */ n.jsxs("div", { className: "space-y-2", children: [
313
+ /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
314
+ /* @__PURE__ */ n.jsx(d, { type: "memory", onClick: C, className: "text-xs", children: "M+" }),
315
+ /* @__PURE__ */ n.jsx(d, { type: "memory", onClick: y, className: "text-xs", children: "M-" }),
316
+ /* @__PURE__ */ n.jsx(d, { type: "memory", onClick: T, className: "text-xs", children: "MR" }),
317
+ /* @__PURE__ */ n.jsx(d, { type: "memory", onClick: v, className: "text-xs", children: "MC" })
318
+ ] }),
319
+ /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
320
+ /* @__PURE__ */ n.jsx(d, { type: "function", onClick: s, children: "C" }),
321
+ /* @__PURE__ */ n.jsx(d, { type: "function", onClick: g, children: "±" }),
322
+ /* @__PURE__ */ n.jsx(d, { type: "function", onClick: f, children: "%" }),
323
+ /* @__PURE__ */ n.jsx(d, { type: "operator", onClick: () => c("÷"), children: "÷" })
324
+ ] }),
325
+ /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
326
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("7"), children: "7" }),
327
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("8"), children: "8" }),
328
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("9"), children: "9" }),
329
+ /* @__PURE__ */ n.jsx(d, { type: "operator", onClick: () => c("×"), children: "×" })
330
+ ] }),
331
+ /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
332
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("4"), children: "4" }),
333
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("5"), children: "5" }),
334
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("6"), children: "6" }),
335
+ /* @__PURE__ */ n.jsx(d, { type: "operator", onClick: () => c("-"), children: "-" })
336
+ ] }),
337
+ /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
338
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("1"), children: "1" }),
339
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("2"), children: "2" }),
340
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("3"), children: "3" }),
341
+ /* @__PURE__ */ n.jsx(d, { type: "operator", onClick: () => c("+"), children: "+" })
342
+ ] }),
343
+ /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-2", children: [
344
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: () => r("0"), className: "col-span-2", children: "0" }),
345
+ /* @__PURE__ */ n.jsx(d, { type: "number", onClick: t, children: "." }),
346
+ /* @__PURE__ */ n.jsx(d, { type: "function", onClick: o, children: "⌫" }),
347
+ /* @__PURE__ */ n.jsx(d, { type: "equals", onClick: u, children: "=" })
348
+ ] })
349
+ ] }));
350
+ ae.displayName = "Keypad";
351
+ const me = () => {
352
+ const [r, t] = R("0"), [c, u] = R(0), [s, o] = R(null), [f, g] = R(null), [C, y] = R(!1), [T, v] = R("");
353
+ ce(() => {
354
+ const i = new MutationObserver(() => {
355
+ t((p) => p);
356
+ });
357
+ return i.observe(document.documentElement, { attributes: !0 }), () => i.disconnect();
358
+ }, []);
359
+ const O = (i) => {
360
+ C ? (t(String(i)), y(!1)) : t(r === "0" ? String(i) : r + i);
361
+ }, S = () => {
362
+ C ? (t("0."), y(!1)) : r.includes(".") || t(r + ".");
363
+ }, P = () => {
364
+ t("0"), o(null), g(null), y(!1), v("");
365
+ }, $ = () => {
366
+ r.length > 1 ? t(r.slice(0, -1)) : t("0");
367
+ }, w = () => {
368
+ t((i) => String(-parseFloat(i)));
369
+ }, F = () => {
370
+ t((i) => String(parseFloat(i) / 100));
371
+ }, M = (i) => {
372
+ const p = parseFloat(r);
373
+ if (f === null)
374
+ v(`${p} ${i}`), g(p);
375
+ else {
376
+ v(`${f} ${s} ${p} =`);
377
+ const k = f || 0;
378
+ let j;
379
+ switch (s) {
380
+ case "+":
381
+ j = k + p;
382
+ break;
383
+ case "-":
384
+ j = k - p;
385
+ break;
386
+ case "×":
387
+ j = k * p;
388
+ break;
389
+ case "÷":
390
+ j = k / p;
391
+ break;
392
+ default:
393
+ j = p;
394
+ }
395
+ g(j), t(String(j)), v(`${j} ${i}`);
396
+ }
397
+ y(!0), o(i);
398
+ }, D = () => {
399
+ if (s && f !== null) {
400
+ const i = parseFloat(r), p = f || 0;
401
+ let k;
402
+ switch (s) {
403
+ case "+":
404
+ k = p + i;
405
+ break;
406
+ case "-":
407
+ k = p - i;
408
+ break;
409
+ case "×":
410
+ k = p * i;
411
+ break;
412
+ case "÷":
413
+ k = p / i;
414
+ break;
415
+ default:
416
+ k = i;
417
+ }
418
+ v(`${p} ${s} ${i} =`), t(String(k)), g(k), o(null), y(!0);
419
+ }
420
+ }, Y = () => {
421
+ u((i) => i + parseFloat(r));
422
+ }, l = () => {
423
+ u((i) => i - parseFloat(r));
424
+ }, x = () => {
425
+ t(String(c)), y(!0);
426
+ }, N = () => {
427
+ u(0);
428
+ };
429
+ return /* @__PURE__ */ n.jsxs("div", { className: "max-w-md w-full mx-auto p-4", children: [
430
+ /* @__PURE__ */ n.jsx(
431
+ ne,
432
+ {
433
+ value: r,
434
+ memory: c,
435
+ expression: T
436
+ }
437
+ ),
438
+ /* @__PURE__ */ n.jsx("div", { className: "mt-6", children: /* @__PURE__ */ n.jsx(
439
+ ae,
440
+ {
441
+ onNumber: O,
442
+ onDecimal: S,
443
+ onOperator: M,
444
+ onEquals: D,
445
+ onClear: P,
446
+ onBackspace: $,
447
+ onPercentage: F,
448
+ onToggleSign: w,
449
+ onMemoryAdd: Y,
450
+ onMemorySubtract: l,
451
+ onMemoryRecall: x,
452
+ onMemoryClear: N
453
+ }
454
+ ) })
455
+ ] });
456
+ }, _ = {
264
457
  // Basic operations
265
- add: (r, a) => r + a,
266
- subtract: (r, a) => r - a,
267
- multiply: (r, a) => r * a,
268
- divide: (r, a) => a !== 0 ? r / a : "Error",
458
+ add: (r, t) => r + t,
459
+ subtract: (r, t) => r - t,
460
+ multiply: (r, t) => r * t,
461
+ divide: (r, t) => t !== 0 ? r / t : "Error",
269
462
  // Format number for display
270
463
  formatNumber: (r) => {
271
464
  if (r === "Error") return "Error";
272
- const a = r.toString();
273
- return a.length > 12 ? parseFloat(r).toExponential(6) : a;
465
+ const t = r.toString();
466
+ return t.length > 12 ? parseFloat(r).toExponential(6) : t;
274
467
  },
275
468
  // Calculate percentage
276
469
  percentage: (r) => r / 100,
@@ -293,254 +486,109 @@ const E = {
293
486
  },
294
487
  // Evaluate expression
295
488
  evaluate: (r) => {
296
- const a = [], c = [];
297
- for (r.forEach((l) => {
298
- if (!E.isOperator(l))
299
- a.push(parseFloat(l));
489
+ const t = [], c = [];
490
+ for (r.forEach((s) => {
491
+ if (!_.isOperator(s))
492
+ t.push(parseFloat(s));
300
493
  else {
301
- for (; c.length > 0 && E.isOperator(c[c.length - 1]) && E.getPrecedence(c[c.length - 1]) >= E.getPrecedence(l); )
302
- a.push(c.pop());
303
- c.push(l);
494
+ for (; c.length > 0 && _.isOperator(c[c.length - 1]) && _.getPrecedence(c[c.length - 1]) >= _.getPrecedence(s); )
495
+ t.push(c.pop());
496
+ c.push(s);
304
497
  }
305
498
  }); c.length > 0; )
306
- a.push(c.pop());
307
- const i = [];
308
- return a.forEach((l) => {
309
- if (!E.isOperator(l))
310
- i.push(l);
499
+ t.push(c.pop());
500
+ const u = [];
501
+ return t.forEach((s) => {
502
+ if (!_.isOperator(s))
503
+ u.push(s);
311
504
  else {
312
- const n = i.pop(), p = i.pop();
313
- switch (l) {
505
+ const o = u.pop(), f = u.pop();
506
+ switch (s) {
314
507
  case "+":
315
- i.push(p + n);
508
+ u.push(f + o);
316
509
  break;
317
510
  case "-":
318
- i.push(p - n);
511
+ u.push(f - o);
319
512
  break;
320
513
  case "×":
321
- i.push(p * n);
514
+ u.push(f * o);
322
515
  break;
323
516
  case "÷":
324
- i.push(n !== 0 ? p / n : "Error");
517
+ u.push(o !== 0 ? f / o : "Error");
325
518
  break;
326
519
  }
327
520
  }
328
- }), i[0];
521
+ }), u[0];
329
522
  }
330
- }, ve = () => {
331
- const [r, a] = O("0"), [c, i] = O([]), [l, n] = O(!0), [p, y] = O(0), k = b((o) => {
332
- a((x) => l || x === "0" || x === "Error" ? (n(!1), o) : x.length < 12 ? x + o : x);
333
- }, [l]), w = b(() => {
334
- a((o) => l || o === "0" || o === "Error" ? (n(!1), "0.") : !o.includes(".") && o.length < 12 ? o + "." : o);
335
- }, [l]), g = b((o) => {
336
- i((x) => {
337
- const C = [...x];
338
- return r !== "Error" && C.push(r), C.push(o), C;
339
- }), n(!0);
340
- }, [r]), N = b(() => {
523
+ }, pe = () => {
524
+ const [r, t] = R("0"), [c, u] = R([]), [s, o] = R(!0), [f, g] = R(0), C = E((l) => {
525
+ t((x) => s || x === "0" || x === "Error" ? (o(!1), l) : x.length < 12 ? x + l : x);
526
+ }, [s]), y = E(() => {
527
+ t((l) => s || l === "0" || l === "Error" ? (o(!1), "0.") : !l.includes(".") && l.length < 12 ? l + "." : l);
528
+ }, [s]), T = E((l) => {
529
+ u((x) => {
530
+ const N = [...x];
531
+ return r !== "Error" && N.push(r), N.push(l), N;
532
+ }), o(!0);
533
+ }, [r]), v = E(() => {
341
534
  if (r !== "Error") {
342
- const o = [...c, r], x = E.evaluate(o);
343
- a(E.formatNumber(x)), i([]), n(!0);
535
+ const l = [...c, r], x = _.evaluate(l);
536
+ t(_.formatNumber(x)), u([]), o(!0);
344
537
  }
345
- }, [r, c]), _ = b(() => {
346
- a("0"), i([]), n(!0);
347
- }, []), j = b(() => {
348
- a("0"), n(!0);
349
- }, []), h = b(() => {
350
- a((o) => o.length > 1 && o !== "Error" ? o.slice(0, -1) : "0");
351
- }, []), M = b(() => {
352
- a((o) => {
353
- if (o !== "Error") {
354
- const x = E.percentage(parseFloat(o));
355
- return E.formatNumber(x);
538
+ }, [r, c]), O = E(() => {
539
+ t("0"), u([]), o(!0);
540
+ }, []), S = E(() => {
541
+ t("0"), o(!0);
542
+ }, []), P = E(() => {
543
+ t((l) => l.length > 1 && l !== "Error" ? l.slice(0, -1) : "0");
544
+ }, []), $ = E(() => {
545
+ t((l) => {
546
+ if (l !== "Error") {
547
+ const x = _.percentage(parseFloat(l));
548
+ return _.formatNumber(x);
356
549
  }
357
- return o;
550
+ return l;
358
551
  });
359
- }, []), v = b(() => {
360
- a((o) => {
361
- if (o !== "Error" && o !== "0") {
362
- const x = E.toggleSign(parseFloat(o));
363
- return E.formatNumber(x);
552
+ }, []), w = E(() => {
553
+ t((l) => {
554
+ if (l !== "Error" && l !== "0") {
555
+ const x = _.toggleSign(parseFloat(l));
556
+ return _.formatNumber(x);
364
557
  }
365
- return o;
558
+ return l;
366
559
  });
367
- }, []), D = b(() => {
368
- r !== "Error" && (y((o) => o + parseFloat(r)), n(!0));
369
- }, [r]), $ = b(() => {
370
- r !== "Error" && (y((o) => o - parseFloat(r)), n(!0));
371
- }, [r]), F = b(() => {
372
- a(E.formatNumber(p)), n(!0);
373
- }, [p]), Y = b(() => {
374
- y(0);
560
+ }, []), F = E(() => {
561
+ r !== "Error" && (g((l) => l + parseFloat(r)), o(!0));
562
+ }, [r]), M = E(() => {
563
+ r !== "Error" && (g((l) => l - parseFloat(r)), o(!0));
564
+ }, [r]), D = E(() => {
565
+ t(_.formatNumber(f)), o(!0);
566
+ }, [f]), Y = E(() => {
567
+ g(0);
375
568
  }, []);
376
569
  return {
377
570
  display: r,
378
571
  expression: c,
379
- memory: p,
380
- handleNumber: k,
381
- handleDecimal: w,
382
- handleOperator: g,
383
- handleEquals: N,
384
- handleClear: _,
385
- handleClearEntry: j,
386
- handleBackspace: h,
387
- handlePercentage: M,
388
- handleToggleSign: v,
389
- handleMemoryAdd: D,
390
- handleMemorySubtract: $,
391
- handleMemoryRecall: F,
572
+ memory: f,
573
+ handleNumber: C,
574
+ handleDecimal: y,
575
+ handleOperator: T,
576
+ handleEquals: v,
577
+ handleClear: O,
578
+ handleClearEntry: S,
579
+ handleBackspace: P,
580
+ handlePercentage: $,
581
+ handleToggleSign: w,
582
+ handleMemoryAdd: F,
583
+ handleMemorySubtract: M,
584
+ handleMemoryRecall: D,
392
585
  handleMemoryClear: Y
393
586
  };
394
- }, ee = U(({
395
- value: r,
396
- expression: a,
397
- memory: c
398
- }) => {
399
- const [i, l] = O(/* @__PURE__ */ new Date());
400
- return ce(() => {
401
- const n = setInterval(() => l(/* @__PURE__ */ new Date()), 1e3);
402
- return () => clearInterval(n);
403
- }, []), /* @__PURE__ */ t.jsxs("div", { className: "bg-card rounded-xl p-6 shadow-inner border border-custom", children: [
404
- /* @__PURE__ */ t.jsxs("div", { className: "flex justify-between items-center mb-4 text-sm text-secondary", children: [
405
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
406
- /* @__PURE__ */ t.jsx(ie, { className: "w-4 h-4" }),
407
- /* @__PURE__ */ t.jsx("span", { children: "Standard" })
408
- ] }),
409
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
410
- c !== 0 && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-1 text-purple-600 dark:text-purple-400", children: [
411
- /* @__PURE__ */ t.jsx("span", { className: "text-xs", children: "M" }),
412
- /* @__PURE__ */ t.jsx("span", { children: c })
413
- ] }),
414
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-1", children: [
415
- /* @__PURE__ */ t.jsx(ue, { className: "w-3 h-3" }),
416
- /* @__PURE__ */ t.jsx("span", { children: i.toLocaleTimeString() })
417
- ] })
418
- ] })
419
- ] }),
420
- a.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "text-right text-sm text-secondary mb-2 font-mono", children: a.join(" ") }),
421
- /* @__PURE__ */ t.jsx("div", { className: "text-right", children: /* @__PURE__ */ t.jsx("div", { className: "text-5xl font-bold text-primary font-mono truncate", children: r }) }),
422
- /* @__PURE__ */ t.jsx("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-1 text-xs text-secondary opacity-60", children: [
423
- /* @__PURE__ */ t.jsx(me, { className: "w-3 h-3" }),
424
- /* @__PURE__ */ t.jsx("span", { className: "font-mono", children: r !== "Error" ? parseInt(r).toString(2).slice(0, 16) : "ERROR" })
425
- ] }) })
426
- ] });
427
- });
428
- ee.displayName = "Display";
429
- const m = U(({
430
- children: r,
431
- onClick: a,
432
- type: c = "number",
433
- size: i = "normal",
434
- className: l = ""
435
- }) => {
436
- const n = {
437
- small: "px-3 py-2 text-sm",
438
- normal: "px-4 py-3 text-base",
439
- large: "px-6 py-4 text-lg"
440
- }, p = {
441
- number: "bg-button-number text-primary",
442
- operator: "bg-button-operator text-white",
443
- function: "bg-button-function text-primary",
444
- equals: "bg-button-equals text-white col-span-2",
445
- memory: "bg-button-memory text-white text-sm"
446
- };
447
- return /* @__PURE__ */ t.jsx(
448
- "button",
449
- {
450
- onClick: a,
451
- className: `
452
- ${n[i]}
453
- ${p[c]}
454
- rounded-lg font-semibold transition-all duration-200
455
- active:scale-95 shadow-sm hover:shadow-md
456
- ${l}
457
- `,
458
- children: r
459
- }
460
- );
461
- });
462
- m.displayName = "Button";
463
- const re = U(({
464
- onNumber: r,
465
- onDecimal: a,
466
- onOperator: c,
467
- onEquals: i,
468
- onClear: l,
469
- onClearEntry: n,
470
- onBackspace: p,
471
- onPercentage: y,
472
- onToggleSign: k,
473
- onMemoryAdd: w,
474
- onMemorySubtract: g,
475
- onMemoryRecall: N,
476
- onMemoryClear: _
477
- }) => {
478
- const j = [7, 8, 9, 4, 5, 6, 1, 2, 3, 0];
479
- return /* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-5 gap-2", children: [
480
- /* @__PURE__ */ t.jsx(m, { type: "memory", onClick: w, size: "small", children: /* @__PURE__ */ t.jsx(de, { className: "w-4 h-4" }) }),
481
- /* @__PURE__ */ t.jsx(m, { type: "memory", onClick: g, size: "small", children: /* @__PURE__ */ t.jsx(fe, { className: "w-4 h-4" }) }),
482
- /* @__PURE__ */ t.jsx(m, { type: "memory", onClick: N, size: "small", children: /* @__PURE__ */ t.jsx(pe, { className: "w-4 h-4" }) }),
483
- /* @__PURE__ */ t.jsx(m, { type: "memory", onClick: _, size: "small", children: /* @__PURE__ */ t.jsx(he, { className: "w-4 h-4" }) }),
484
- /* @__PURE__ */ t.jsx(m, { type: "function", onClick: n, size: "small", children: "CE" }),
485
- /* @__PURE__ */ t.jsx(m, { type: "function", onClick: k, size: "small", children: "±" }),
486
- /* @__PURE__ */ t.jsx(m, { type: "function", onClick: y, size: "small", children: /* @__PURE__ */ t.jsx(xe, { className: "w-4 h-4" }) }),
487
- /* @__PURE__ */ t.jsx(m, { type: "function", onClick: l, size: "small", children: /* @__PURE__ */ t.jsx(be, { className: "w-4 h-4" }) }),
488
- /* @__PURE__ */ t.jsxs(m, { type: "function", onClick: p, size: "small", children: [
489
- /* @__PURE__ */ t.jsx(Ee, { className: "w-4 h-4" }),
490
- " "
491
- ] }),
492
- /* @__PURE__ */ t.jsx(m, { type: "operator", onClick: () => c("÷"), size: "small", children: /* @__PURE__ */ t.jsx(ye, { className: "w-4 h-4" }) }),
493
- j.slice(0, 3).map((h) => /* @__PURE__ */ t.jsx(m, { onClick: () => r(h.toString()), children: h }, h)),
494
- /* @__PURE__ */ t.jsx(m, { type: "operator", onClick: () => c("×"), children: /* @__PURE__ */ t.jsx(je, { className: "w-4 h-4" }) }),
495
- j.slice(3, 6).map((h) => /* @__PURE__ */ t.jsx(m, { onClick: () => r(h.toString()), children: h }, h)),
496
- /* @__PURE__ */ t.jsx(m, { type: "operator", onClick: () => c("-"), children: /* @__PURE__ */ t.jsx(ge, { className: "w-4 h-4" }) }),
497
- j.slice(6, 9).map((h) => /* @__PURE__ */ t.jsx(m, { onClick: () => r(h.toString()), children: h }, h)),
498
- /* @__PURE__ */ t.jsx(m, { type: "operator", onClick: () => c("+"), children: /* @__PURE__ */ t.jsx(Ne, { className: "w-4 h-4" }) }),
499
- /* @__PURE__ */ t.jsx(m, { type: "number", onClick: a, className: "col-span-2", children: "." }),
500
- /* @__PURE__ */ t.jsx(m, { type: "number", onClick: () => r("0"), className: "col-span-2", children: "0" }),
501
- /* @__PURE__ */ t.jsx(m, { type: "equals", onClick: i, className: "col-span-1", children: /* @__PURE__ */ t.jsx(_e, { className: "w-5 h-5" }) })
502
- ] });
503
- });
504
- re.displayName = "Keypad";
505
- const Se = () => {
506
- const r = ve();
507
- return /* @__PURE__ */ t.jsxs("div", { className: "max-w-md w-full mx-auto p-4", children: [
508
- /* @__PURE__ */ t.jsx(
509
- ee,
510
- {
511
- value: r.display,
512
- expression: r.expression,
513
- memory: r.memory
514
- }
515
- ),
516
- /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsx(
517
- re,
518
- {
519
- onNumber: r.handleNumber,
520
- onDecimal: r.handleDecimal,
521
- onOperator: r.handleOperator,
522
- onEquals: r.handleEquals,
523
- onClear: r.handleClear,
524
- onClearEntry: r.handleClearEntry,
525
- onBackspace: r.handleBackspace,
526
- onPercentage: r.handlePercentage,
527
- onToggleSign: r.handleToggleSign,
528
- onMemoryAdd: r.handleMemoryAdd,
529
- onMemorySubtract: r.handleMemorySubtract,
530
- onMemoryRecall: r.handleMemoryRecall,
531
- onMemoryClear: r.handleMemoryClear
532
- }
533
- ) }),
534
- /* @__PURE__ */ t.jsx("div", { className: "mt-4 text-xs text-center text-secondary", children: /* @__PURE__ */ t.jsxs("p", { children: [
535
- "Memory: ",
536
- r.memory
537
- ] }) })
538
- ] });
539
587
  };
540
588
  export {
541
- m as Button,
542
- Se as Calculator,
543
- ee as Display,
544
- re as Keypad,
545
- ve as useCalculator
589
+ d as Button,
590
+ me as Calculator,
591
+ ne as Display,
592
+ ae as Keypad,
593
+ pe as useCalculator
546
594
  };
package/dist/index.umd.js CHANGED
@@ -1,12 +1,6 @@
1
- (function(E,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react"],i):(E=typeof globalThis<"u"?globalThis:E||self,i(E.Calculator={},E.React,E.LucideReact))})(this,(function(E,i,b){"use strict";var A={exports:{}},w={};var X;function ae(){if(X)return w;X=1;var r=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function c(u,o,n){var h=null;if(n!==void 0&&(h=""+n),o.key!==void 0&&(h=""+o.key),"key"in o){n={};for(var g in o)g!=="key"&&(n[g]=o[g])}else n=o;return o=n.ref,{$$typeof:r,type:u,key:h,ref:o!==void 0?o:null,props:n}}return w.Fragment=a,w.jsx=c,w.jsxs=c,w}var T={};var Z;function se(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case I:return"Profiler";case z:return"StrictMode";case y:return"Suspense";case P:return"SuspenseList";case ce:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Y:return"Portal";case W:return e.displayName||"Context";case L:return(e._context.displayName||"Context")+".Consumer";case l:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case oe:return s=e.displayName||null,s!==null?s:r(e.type)||"Memo";case U:s=e._payload,e=e._init;try{return r(e(s))}catch{}}return null}function a(e){return""+e}function c(e){try{a(e);var s=!1}catch{s=!0}if(s){s=console;var m=s.error,f=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return m.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",f),a(e)}}function u(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===U)return"<...>";try{var s=r(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function o(){var e=B.A;return e===null?null:e.getOwner()}function n(){return Error("react-stack-top-frame")}function h(e){if(K.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function g(e,s){function m(){q||(q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}m.isReactWarning=!0,Object.defineProperty(e,"key",{get:m,configurable:!0})}function R(){var e=r(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function S(e,s,m,f,M,V){var p=m.ref;return e={$$typeof:x,type:e,key:s,props:m,_owner:f},(p!==void 0?p:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function C(e,s,m,f,M,V){var p=s.children;if(p!==void 0)if(f)if(ue(p)){for(f=0;f<p.length;f++)N(p[f]);Object.freeze&&Object.freeze(p)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(p);if(K.call(s,"key")){p=r(e);var v=Object.keys(s).filter(function(me){return me!=="key"});f=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",te[p+f]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(_,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],c):(_=typeof globalThis<"u"?globalThis:_||self,c(_.Calculator={},_.React))})(this,(function(_,c){"use strict";var W={exports:{}},F={};var Q;function ne(){if(Q)return F;Q=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function u(f,s,l){var m=null;if(l!==void 0&&(m=""+l),s.key!==void 0&&(m=""+s.key),"key"in s){l={};for(var g in s)g!=="key"&&(l[g]=s[g])}else l=s;return s=l.ref,{$$typeof:t,type:f,key:m,ref:s!==void 0?s:null,props:l}}return F.Fragment=r,F.jsx=u,F.jsxs=u,F}var M={};var Z;function se(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===C?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case V:return"Profiler";case Y:return"StrictMode";case x:return"Suspense";case N:return"SuspenseList";case y:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case D:return"Portal";case L:return e.displayName||"Context";case I:return(e._context.displayName||"Context")+".Consumer";case o:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case i:return n=e.displayName||null,n!==null?n:t(e.type)||"Memo";case p:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function r(e){return""+e}function u(e){try{r(e);var n=!1}catch{n=!0}if(n){n=console;var b=n.error,h=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return b.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",h),r(e)}}function f(e){if(e===w)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===p)return"<...>";try{var n=t(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function s(){var e=B.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function m(e){if(q.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function g(e,n){function b(){$||($=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}b.isReactWarning=!0,Object.defineProperty(e,"key",{get:b,configurable:!0})}function R(){var e=t(this.type);return ee[e]||(ee[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function v(e,n,b,h,U,X){var k=b.ref;return e={$$typeof:P,type:e,key:n,props:b,_owner:h},(k!==void 0?k:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function S(e,n,b,h,U,X){var k=n.children;if(k!==void 0)if(h)if(ue(k)){for(h=0;h<k.length;h++)j(k[h]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(k);if(q.call(n,"key")){k=t(e);var A=Object.keys(n).filter(function(ie){return ie!=="key"});h=0<A.length?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}",ae[k+h]||(A=0<A.length?"{"+A.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,f,p,v,p),te[p+f]=!0)}if(p=null,m!==void 0&&(c(m),p=""+m),h(s)&&(c(s.key),p=""+s.key),"key"in s){m={};for(var G in s)G!=="key"&&(m[G]=s[G])}else m=s;return p&&g(m,typeof e=="function"?e.displayName||e.name||"Unknown":e),S(e,p,m,o(),M,V)}function N(e){_(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===U&&(e._payload.status==="fulfilled"?_(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function _(e){return typeof e=="object"&&e!==null&&e.$$typeof===x}var k=i,x=Symbol.for("react.transitional.element"),Y=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),W=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),ce=Symbol.for("react.activity"),ie=Symbol.for("react.client.reference"),B=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=Object.prototype.hasOwnProperty,ue=Array.isArray,J=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(e){return e()}};var q,$={},ee=k.react_stack_bottom_frame.bind(k,n)(),re=J(u(n)),te={};T.Fragment=O,T.jsx=function(e,s,m){var f=1e4>B.recentlyCreatedOwnerStacks++;return C(e,s,m,!1,f?Error("react-stack-top-frame"):ee,f?J(u(e)):re)},T.jsxs=function(e,s,m){var f=1e4>B.recentlyCreatedOwnerStacks++;return C(e,s,m,!0,f?Error("react-stack-top-frame"):ee,f?J(u(e)):re)}})()),T}var H;function ne(){return H||(H=1,process.env.NODE_ENV==="production"?A.exports=ae():A.exports=se()),A.exports}var t=ne();const j={add:(r,a)=>r+a,subtract:(r,a)=>r-a,multiply:(r,a)=>r*a,divide:(r,a)=>a!==0?r/a:"Error",formatNumber:r=>{if(r==="Error")return"Error";const a=r.toString();return a.length>12?parseFloat(r).toExponential(6):a},percentage:r=>r/100,toggleSign:r=>-r,isOperator:r=>["+","-","×","÷"].includes(r),getPrecedence:r=>{switch(r){case"+":case"-":return 1;case"×":case"÷":return 2;default:return 0}},evaluate:r=>{const a=[],c=[];for(r.forEach(o=>{if(!j.isOperator(o))a.push(parseFloat(o));else{for(;c.length>0&&j.isOperator(c[c.length-1])&&j.getPrecedence(c[c.length-1])>=j.getPrecedence(o);)a.push(c.pop());c.push(o)}});c.length>0;)a.push(c.pop());const u=[];return a.forEach(o=>{if(!j.isOperator(o))u.push(o);else{const n=u.pop(),h=u.pop();switch(o){case"+":u.push(h+n);break;case"-":u.push(h-n);break;case"×":u.push(h*n);break;case"÷":u.push(n!==0?h/n:"Error");break}}}),u[0]}},Q=()=>{const[r,a]=i.useState("0"),[c,u]=i.useState([]),[o,n]=i.useState(!0),[h,g]=i.useState(0),R=i.useCallback(l=>{a(y=>o||y==="0"||y==="Error"?(n(!1),l):y.length<12?y+l:y)},[o]),S=i.useCallback(()=>{a(l=>o||l==="0"||l==="Error"?(n(!1),"0."):!l.includes(".")&&l.length<12?l+".":l)},[o]),C=i.useCallback(l=>{u(y=>{const P=[...y];return r!=="Error"&&P.push(r),P.push(l),P}),n(!0)},[r]),N=i.useCallback(()=>{if(r!=="Error"){const l=[...c,r],y=j.evaluate(l);a(j.formatNumber(y)),u([]),n(!0)}},[r,c]),_=i.useCallback(()=>{a("0"),u([]),n(!0)},[]),k=i.useCallback(()=>{a("0"),n(!0)},[]),x=i.useCallback(()=>{a(l=>l.length>1&&l!=="Error"?l.slice(0,-1):"0")},[]),Y=i.useCallback(()=>{a(l=>{if(l!=="Error"){const y=j.percentage(parseFloat(l));return j.formatNumber(y)}return l})},[]),O=i.useCallback(()=>{a(l=>{if(l!=="Error"&&l!=="0"){const y=j.toggleSign(parseFloat(l));return j.formatNumber(y)}return l})},[]),z=i.useCallback(()=>{r!=="Error"&&(g(l=>l+parseFloat(r)),n(!0))},[r]),I=i.useCallback(()=>{r!=="Error"&&(g(l=>l-parseFloat(r)),n(!0))},[r]),L=i.useCallback(()=>{a(j.formatNumber(h)),n(!0)},[h]),W=i.useCallback(()=>{g(0)},[]);return{display:r,expression:c,memory:h,handleNumber:R,handleDecimal:S,handleOperator:C,handleEquals:N,handleClear:_,handleClearEntry:k,handleBackspace:x,handlePercentage:Y,handleToggleSign:O,handleMemoryAdd:z,handleMemorySubtract:I,handleMemoryRecall:L,handleMemoryClear:W}},D=i.memo(({value:r,expression:a,memory:c})=>{const[u,o]=i.useState(new Date);return i.useEffect(()=>{const n=setInterval(()=>o(new Date),1e3);return()=>clearInterval(n)},[]),t.jsxs("div",{className:"bg-card rounded-xl p-6 shadow-inner border border-custom",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4 text-sm text-secondary",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(b.Calculator,{className:"w-4 h-4"}),t.jsx("span",{children:"Standard"})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[c!==0&&t.jsxs("div",{className:"flex items-center gap-1 text-purple-600 dark:text-purple-400",children:[t.jsx("span",{className:"text-xs",children:"M"}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(b.Clock,{className:"w-3 h-3"}),t.jsx("span",{children:u.toLocaleTimeString()})]})]})]}),a.length>0&&t.jsx("div",{className:"text-right text-sm text-secondary mb-2 font-mono",children:a.join(" ")}),t.jsx("div",{className:"text-right",children:t.jsx("div",{className:"text-5xl font-bold text-primary font-mono truncate",children:r})}),t.jsx("div",{className:"flex justify-end mt-2",children:t.jsxs("div",{className:"flex items-center gap-1 text-xs text-secondary opacity-60",children:[t.jsx(b.Zap,{className:"w-3 h-3"}),t.jsx("span",{className:"font-mono",children:r!=="Error"?parseInt(r).toString(2).slice(0,16):"ERROR"})]})})]})});D.displayName="Display";const d=i.memo(({children:r,onClick:a,type:c="number",size:u="normal",className:o=""})=>{const n={small:"px-3 py-2 text-sm",normal:"px-4 py-3 text-base",large:"px-6 py-4 text-lg"},h={number:"bg-button-number text-primary",operator:"bg-button-operator text-white",function:"bg-button-function text-primary",equals:"bg-button-equals text-white col-span-2",memory:"bg-button-memory text-white text-sm"};return t.jsx("button",{onClick:a,className:`
7
- ${n[u]}
8
- ${h[c]}
9
- rounded-lg font-semibold transition-all duration-200
10
- active:scale-95 shadow-sm hover:shadow-md
11
- ${o}
12
- `,children:r})});d.displayName="Button";const F=i.memo(({onNumber:r,onDecimal:a,onOperator:c,onEquals:u,onClear:o,onClearEntry:n,onBackspace:h,onPercentage:g,onToggleSign:R,onMemoryAdd:S,onMemorySubtract:C,onMemoryRecall:N,onMemoryClear:_})=>{const k=[7,8,9,4,5,6,1,2,3,0];return t.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[t.jsx(d,{type:"memory",onClick:S,size:"small",children:t.jsx(b.PlusCircle,{className:"w-4 h-4"})}),t.jsx(d,{type:"memory",onClick:C,size:"small",children:t.jsx(b.MinusCircle,{className:"w-4 h-4"})}),t.jsx(d,{type:"memory",onClick:N,size:"small",children:t.jsx(b.RotateCw,{className:"w-4 h-4"})}),t.jsx(d,{type:"memory",onClick:_,size:"small",children:t.jsx(b.Trash2,{className:"w-4 h-4"})}),t.jsx(d,{type:"function",onClick:n,size:"small",children:"CE"}),t.jsx(d,{type:"function",onClick:R,size:"small",children:"±"}),t.jsx(d,{type:"function",onClick:g,size:"small",children:t.jsx(b.Percent,{className:"w-4 h-4"})}),t.jsx(d,{type:"function",onClick:o,size:"small",children:t.jsx(b.RotateCcw,{className:"w-4 h-4"})}),t.jsxs(d,{type:"function",onClick:h,size:"small",children:[t.jsx(b.Delete,{className:"w-4 h-4"})," "]}),t.jsx(d,{type:"operator",onClick:()=>c("÷"),size:"small",children:t.jsx(b.Divide,{className:"w-4 h-4"})}),k.slice(0,3).map(x=>t.jsx(d,{onClick:()=>r(x.toString()),children:x},x)),t.jsx(d,{type:"operator",onClick:()=>c("×"),children:t.jsx(b.X,{className:"w-4 h-4"})}),k.slice(3,6).map(x=>t.jsx(d,{onClick:()=>r(x.toString()),children:x},x)),t.jsx(d,{type:"operator",onClick:()=>c("-"),children:t.jsx(b.Minus,{className:"w-4 h-4"})}),k.slice(6,9).map(x=>t.jsx(d,{onClick:()=>r(x.toString()),children:x},x)),t.jsx(d,{type:"operator",onClick:()=>c("+"),children:t.jsx(b.Plus,{className:"w-4 h-4"})}),t.jsx(d,{type:"number",onClick:a,className:"col-span-2",children:"."}),t.jsx(d,{type:"number",onClick:()=>r("0"),className:"col-span-2",children:"0"}),t.jsx(d,{type:"equals",onClick:u,className:"col-span-1",children:t.jsx(b.Equal,{className:"w-5 h-5"})})]})});F.displayName="Keypad";const le=()=>{const r=Q();return t.jsxs("div",{className:"max-w-md w-full mx-auto p-4",children:[t.jsx(D,{value:r.display,expression:r.expression,memory:r.memory}),t.jsx("div",{className:"mt-6",children:t.jsx(F,{onNumber:r.handleNumber,onDecimal:r.handleDecimal,onOperator:r.handleOperator,onEquals:r.handleEquals,onClear:r.handleClear,onClearEntry:r.handleClearEntry,onBackspace:r.handleBackspace,onPercentage:r.handlePercentage,onToggleSign:r.handleToggleSign,onMemoryAdd:r.handleMemoryAdd,onMemorySubtract:r.handleMemorySubtract,onMemoryRecall:r.handleMemoryRecall,onMemoryClear:r.handleMemoryClear})}),t.jsx("div",{className:"mt-4 text-xs text-center text-secondary",children:t.jsxs("p",{children:["Memory: ",r.memory]})})]})};E.Button=d,E.Calculator=le,E.Display=D,E.Keypad=F,E.useCalculator=Q,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
6
+ <%s key={someKey} {...props} />`,h,k,A,k),ae[k+h]=!0)}if(k=null,b!==void 0&&(u(b),k=""+b),m(n)&&(u(n.key),k=""+n.key),"key"in n){b={};for(var H in n)H!=="key"&&(b[H]=n[H])}else b=n;return k&&g(b,typeof e=="function"?e.displayName||e.name||"Unknown":e),v(e,k,b,s(),U,X)}function j(e){O(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===p&&(e._payload.status==="fulfilled"?O(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function O(e){return typeof e=="object"&&e!==null&&e.$$typeof===P}var T=c,P=Symbol.for("react.transitional.element"),D=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),Y=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),L=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),i=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),B=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,ue=Array.isArray,G=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(e){return e()}};var $,ee={},te=T.react_stack_bottom_frame.bind(T,l)(),re=G(f(l)),ae={};M.Fragment=w,M.jsx=function(e,n,b){var h=1e4>B.recentlyCreatedOwnerStacks++;return S(e,n,b,!1,h?Error("react-stack-top-frame"):te,h?G(f(e)):re)},M.jsxs=function(e,n,b){var h=1e4>B.recentlyCreatedOwnerStacks++;return S(e,n,b,!0,h?Error("react-stack-top-frame"):te,h?G(f(e)):re)}})()),M}var K;function le(){return K||(K=1,process.env.NODE_ENV==="production"?W.exports=ne():W.exports=se()),W.exports}var a=le();const J=c.memo(({value:t,memory:r,expression:u})=>a.jsxs("div",{className:"border border-white/30 rounded-2xl p-6 bg-black/5",children:[a.jsx("div",{className:"text-right text-sm text-blue-600 dark:text-blue-400 font-mono mb-1 h-5 opacity-70",children:u}),a.jsx("div",{className:"text-right",children:a.jsx("div",{className:"text-6xl font-light text-blue-600 dark:text-blue-400 font-mono tracking-tight",children:t})}),r!==0&&a.jsxs("div",{className:"absolute top-2 left-2 text-xs border border-white/30 rounded-full px-2 py-1 bg-black/5 text-blue-600 dark:text-blue-400 font-medium",children:["M=",r]})]}));J.displayName="Display";const d=c.memo(({children:t,onClick:r,type:u="number",className:f=""})=>{const s="px-4 py-3 text-base rounded-lg font-semibold transition-all duration-200 active:scale-95 shadow-sm border border-white/30 hover:border-white/60",l={number:"bg-black/5 text-blue-600 dark:text-blue-400 hover:bg-black/10",operator:"bg-black/10 text-blue-600 dark:text-blue-400 hover:bg-black/20",function:"bg-black/5 text-blue-600 dark:text-blue-400 hover:bg-black/10",equals:"bg-black/10 text-blue-600 dark:text-blue-400 hover:bg-black/20",memory:"bg-black/5 text-blue-600 dark:text-blue-400 hover:bg-black/10 text-sm"};return a.jsx("button",{onClick:r,className:`${s} ${l[u]} ${f}`,children:t})});d.displayName="Button";const z=c.memo(({onNumber:t,onDecimal:r,onOperator:u,onEquals:f,onClear:s,onBackspace:l,onPercentage:m,onToggleSign:g,onMemoryAdd:R,onMemorySubtract:v,onMemoryRecall:S,onMemoryClear:j})=>a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsx(d,{type:"memory",onClick:R,className:"text-xs",children:"M+"}),a.jsx(d,{type:"memory",onClick:v,className:"text-xs",children:"M-"}),a.jsx(d,{type:"memory",onClick:S,className:"text-xs",children:"MR"}),a.jsx(d,{type:"memory",onClick:j,className:"text-xs",children:"MC"})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsx(d,{type:"function",onClick:s,children:"C"}),a.jsx(d,{type:"function",onClick:g,children:"±"}),a.jsx(d,{type:"function",onClick:m,children:"%"}),a.jsx(d,{type:"operator",onClick:()=>u("÷"),children:"÷"})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsx(d,{type:"number",onClick:()=>t("7"),children:"7"}),a.jsx(d,{type:"number",onClick:()=>t("8"),children:"8"}),a.jsx(d,{type:"number",onClick:()=>t("9"),children:"9"}),a.jsx(d,{type:"operator",onClick:()=>u("×"),children:"×"})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsx(d,{type:"number",onClick:()=>t("4"),children:"4"}),a.jsx(d,{type:"number",onClick:()=>t("5"),children:"5"}),a.jsx(d,{type:"number",onClick:()=>t("6"),children:"6"}),a.jsx(d,{type:"operator",onClick:()=>u("-"),children:"-"})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsx(d,{type:"number",onClick:()=>t("1"),children:"1"}),a.jsx(d,{type:"number",onClick:()=>t("2"),children:"2"}),a.jsx(d,{type:"number",onClick:()=>t("3"),children:"3"}),a.jsx(d,{type:"operator",onClick:()=>u("+"),children:"+"})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsx(d,{type:"number",onClick:()=>t("0"),className:"col-span-2",children:"0"}),a.jsx(d,{type:"number",onClick:r,children:"."}),a.jsx(d,{type:"function",onClick:l,children:"⌫"}),a.jsx(d,{type:"equals",onClick:f,children:"="})]})]}));z.displayName="Keypad";const oe=()=>{const[t,r]=c.useState("0"),[u,f]=c.useState(0),[s,l]=c.useState(null),[m,g]=c.useState(null),[R,v]=c.useState(!1),[S,j]=c.useState("");c.useEffect(()=>{const i=new MutationObserver(()=>{r(p=>p)});return i.observe(document.documentElement,{attributes:!0}),()=>i.disconnect()},[]);const O=i=>{R?(r(String(i)),v(!1)):r(t==="0"?String(i):t+i)},T=()=>{R?(r("0."),v(!1)):t.includes(".")||r(t+".")},P=()=>{r("0"),l(null),g(null),v(!1),j("")},D=()=>{t.length>1?r(t.slice(0,-1)):r("0")},w=()=>{r(i=>String(-parseFloat(i)))},Y=()=>{r(i=>String(parseFloat(i)/100))},V=i=>{const p=parseFloat(t);if(m===null)j(`${p} ${i}`),g(p);else{j(`${m} ${s} ${p} =`);const y=m||0;let C;switch(s){case"+":C=y+p;break;case"-":C=y-p;break;case"×":C=y*p;break;case"÷":C=y/p;break;default:C=p}g(C),r(String(C)),j(`${C} ${i}`)}v(!0),l(i)},I=()=>{if(s&&m!==null){const i=parseFloat(t),p=m||0;let y;switch(s){case"+":y=p+i;break;case"-":y=p-i;break;case"×":y=p*i;break;case"÷":y=p/i;break;default:y=i}j(`${p} ${s} ${i} =`),r(String(y)),g(y),l(null),v(!0)}},L=()=>{f(i=>i+parseFloat(t))},o=()=>{f(i=>i-parseFloat(t))},x=()=>{r(String(u)),v(!0)},N=()=>{f(0)};return a.jsxs("div",{className:"max-w-md w-full mx-auto p-4",children:[a.jsx(J,{value:t,memory:u,expression:S}),a.jsx("div",{className:"mt-6",children:a.jsx(z,{onNumber:O,onDecimal:T,onOperator:V,onEquals:I,onClear:P,onBackspace:D,onPercentage:Y,onToggleSign:w,onMemoryAdd:L,onMemorySubtract:o,onMemoryRecall:x,onMemoryClear:N})})]})},E={add:(t,r)=>t+r,subtract:(t,r)=>t-r,multiply:(t,r)=>t*r,divide:(t,r)=>r!==0?t/r:"Error",formatNumber:t=>{if(t==="Error")return"Error";const r=t.toString();return r.length>12?parseFloat(t).toExponential(6):r},percentage:t=>t/100,toggleSign:t=>-t,isOperator:t=>["+","-","×","÷"].includes(t),getPrecedence:t=>{switch(t){case"+":case"-":return 1;case"×":case"÷":return 2;default:return 0}},evaluate:t=>{const r=[],u=[];for(t.forEach(s=>{if(!E.isOperator(s))r.push(parseFloat(s));else{for(;u.length>0&&E.isOperator(u[u.length-1])&&E.getPrecedence(u[u.length-1])>=E.getPrecedence(s);)r.push(u.pop());u.push(s)}});u.length>0;)r.push(u.pop());const f=[];return r.forEach(s=>{if(!E.isOperator(s))f.push(s);else{const l=f.pop(),m=f.pop();switch(s){case"+":f.push(m+l);break;case"-":f.push(m-l);break;case"×":f.push(m*l);break;case"÷":f.push(l!==0?m/l:"Error");break}}}),f[0]}},ce=()=>{const[t,r]=c.useState("0"),[u,f]=c.useState([]),[s,l]=c.useState(!0),[m,g]=c.useState(0),R=c.useCallback(o=>{r(x=>s||x==="0"||x==="Error"?(l(!1),o):x.length<12?x+o:x)},[s]),v=c.useCallback(()=>{r(o=>s||o==="0"||o==="Error"?(l(!1),"0."):!o.includes(".")&&o.length<12?o+".":o)},[s]),S=c.useCallback(o=>{f(x=>{const N=[...x];return t!=="Error"&&N.push(t),N.push(o),N}),l(!0)},[t]),j=c.useCallback(()=>{if(t!=="Error"){const o=[...u,t],x=E.evaluate(o);r(E.formatNumber(x)),f([]),l(!0)}},[t,u]),O=c.useCallback(()=>{r("0"),f([]),l(!0)},[]),T=c.useCallback(()=>{r("0"),l(!0)},[]),P=c.useCallback(()=>{r(o=>o.length>1&&o!=="Error"?o.slice(0,-1):"0")},[]),D=c.useCallback(()=>{r(o=>{if(o!=="Error"){const x=E.percentage(parseFloat(o));return E.formatNumber(x)}return o})},[]),w=c.useCallback(()=>{r(o=>{if(o!=="Error"&&o!=="0"){const x=E.toggleSign(parseFloat(o));return E.formatNumber(x)}return o})},[]),Y=c.useCallback(()=>{t!=="Error"&&(g(o=>o+parseFloat(t)),l(!0))},[t]),V=c.useCallback(()=>{t!=="Error"&&(g(o=>o-parseFloat(t)),l(!0))},[t]),I=c.useCallback(()=>{r(E.formatNumber(m)),l(!0)},[m]),L=c.useCallback(()=>{g(0)},[]);return{display:t,expression:u,memory:m,handleNumber:R,handleDecimal:v,handleOperator:S,handleEquals:j,handleClear:O,handleClearEntry:T,handleBackspace:P,handlePercentage:D,handleToggleSign:w,handleMemoryAdd:Y,handleMemorySubtract:V,handleMemoryRecall:I,handleMemoryClear:L}};_.Button=d,_.Calculator=oe,_.Display=J,_.Keypad=z,_.useCalculator=ce,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,16 +1,12 @@
1
-
2
1
  {
3
2
  "name": "@birimengo/calculator",
4
- "version": "1.0.2",
3
+ "version": "1.0.4",
5
4
  "description": "A beautiful calculator component with memory functions",
6
5
  "main": "dist/index.js",
7
6
  "module": "dist/index.es.js",
8
- "unpkg": "dist/index.umd.js",
9
- "types": "dist/index.d.ts",
10
7
  "files": [
11
8
  "dist",
12
- "README.md",
13
- "LICENSE"
9
+ "README.md"
14
10
  ],
15
11
  "scripts": {
16
12
  "dev": "vite",
@@ -18,25 +14,6 @@
18
14
  "prepublishOnly": "npm run build",
19
15
  "preview": "vite preview"
20
16
  },
21
- "keywords": [
22
- "react",
23
- "calculator",
24
- "component",
25
- "ui",
26
- "math",
27
- "memory-calculator",
28
- "bizcore"
29
- ],
30
- "author": "Your Name <your.email@example.com>",
31
- "license": "MIT",
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/birimengo/calculator.git"
35
- },
36
- "bugs": {
37
- "url": "https://github.com/birimengo/calculator/issues"
38
- },
39
- "homepage": "https://github.com/birimengo/calculator#readme",
40
17
  "peerDependencies": {
41
18
  "react": ">=18.0.0",
42
19
  "react-dom": ">=18.0.0"
@@ -45,20 +22,16 @@
45
22
  "lucide-react": "^0.577.0"
46
23
  },
47
24
  "devDependencies": {
48
- "@eslint/js": "^9.29.0",
49
- "@tailwindcss/vite": "^4.2.1",
50
- "@types/react": "^19.1.8",
51
- "@types/react-dom": "^19.1.6",
52
25
  "@vitejs/plugin-react-swc": "^3.11.0",
53
- "autoprefixer": "^10.4.21",
54
- "eslint": "^9.29.0",
55
- "eslint-plugin-react-hooks": "^5.2.0",
56
- "eslint-plugin-react-refresh": "^0.4.20",
57
- "globals": "^16.2.0",
58
- "postcss": "^8.5.3",
59
26
  "react": "^19.1.0",
60
27
  "react-dom": "^19.1.0",
61
- "tailwindcss": "^4.2.1",
62
28
  "vite": "^7.0.0"
63
- }
64
- }
29
+ },
30
+ "keywords": [
31
+ "react",
32
+ "calculator",
33
+ "bizcore"
34
+ ],
35
+ "author": "Your Name",
36
+ "license": "MIT"
37
+ }