@birimengo/calculator 1.0.0 → 1.0.2

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,31 +1,31 @@
1
- import le, { useState as j, useCallback as b, memo as U, useEffect as ce } from "react";
2
- import { Calculator as ie, Clock as ue, Zap as de, PlusCircle as me, MinusCircle as fe, RotateCw as he, Trash2 as pe, Percent as xe, RotateCcw as be, Delete as ye, Divide as ge, X as Ee, Minus as je, Plus as Ne, Equal as ke, Cloud as we, Moon as _e, Sun as Re } from "lucide-react";
3
- var A = { exports: {} }, S = {};
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
4
  var H;
5
- function ve() {
6
- if (H) return S;
5
+ function Re() {
6
+ if (H) return T;
7
7
  H = 1;
8
8
  var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function c(i, o, n) {
10
- var h = null;
11
- if (n !== void 0 && (h = "" + n), o.key !== void 0 && (h = "" + o.key), "key" in o) {
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
12
  n = {};
13
- for (var g in o)
14
- g !== "key" && (n[g] = o[g]);
15
- } else n = o;
16
- return o = n.ref, {
13
+ for (var y in l)
14
+ y !== "key" && (n[y] = l[y]);
15
+ } else n = l;
16
+ return l = n.ref, {
17
17
  $$typeof: r,
18
18
  type: i,
19
- key: h,
20
- ref: o !== void 0 ? o : null,
19
+ key: p,
20
+ ref: l !== void 0 ? l : null,
21
21
  props: n
22
22
  };
23
23
  }
24
- return S.Fragment = a, S.jsx = c, S.jsxs = c, S;
24
+ return T.Fragment = a, T.jsx = c, T.jsxs = c, T;
25
25
  }
26
- var O = {};
26
+ var S = {};
27
27
  var Q;
28
- function Ce() {
28
+ function ke() {
29
29
  return Q || (Q = 1, process.env.NODE_ENV !== "production" && (function() {
30
30
  function r(e) {
31
31
  if (e == null) return null;
@@ -33,7 +33,7 @@ function Ce() {
33
33
  return e.$$typeof === se ? null : e.displayName || e.name || null;
34
34
  if (typeof e == "string") return e;
35
35
  switch (e) {
36
- case C:
36
+ case v:
37
37
  return "Fragment";
38
38
  case $:
39
39
  return "Profiler";
@@ -41,7 +41,7 @@ function Ce() {
41
41
  return "StrictMode";
42
42
  case x:
43
43
  return "Suspense";
44
- case T:
44
+ case C:
45
45
  return "SuspenseList";
46
46
  case ae:
47
47
  return "Activity";
@@ -56,12 +56,12 @@ function Ce() {
56
56
  return e.displayName || "Context";
57
57
  case F:
58
58
  return (e._context.displayName || "Context") + ".Consumer";
59
- case l:
59
+ case o:
60
60
  var s = e.render;
61
61
  return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
62
  case te:
63
63
  return s = e.displayName || null, s !== null ? s : r(e.type) || "Memo";
64
- case I:
64
+ case z:
65
65
  s = e._payload, e = e._init;
66
66
  try {
67
67
  return r(e(s));
@@ -82,17 +82,17 @@ function Ce() {
82
82
  }
83
83
  if (s) {
84
84
  s = console;
85
- var u = s.error, m = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ var u = s.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
86
  return u.call(
87
87
  s,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- m
89
+ d
90
90
  ), a(e);
91
91
  }
92
92
  }
93
93
  function i(e) {
94
- if (e === C) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === I)
94
+ if (e === v) return "<>";
95
+ if (typeof e == "object" && e !== null && e.$$typeof === z)
96
96
  return "<...>";
97
97
  try {
98
98
  var s = r(e);
@@ -101,21 +101,21 @@ function Ce() {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function o() {
105
- var e = z.A;
104
+ function l() {
105
+ var e = I.A;
106
106
  return e === null ? null : e.getOwner();
107
107
  }
108
108
  function n() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function h(e) {
111
+ function p(e) {
112
112
  if (J.call(e, "key")) {
113
113
  var s = Object.getOwnPropertyDescriptor(e, "key").get;
114
114
  if (s && s.isReactWarning) return !1;
115
115
  }
116
116
  return e.key !== void 0;
117
117
  }
118
- function g(e, s) {
118
+ function y(e, s) {
119
119
  function u() {
120
120
  V || (V = !0, console.error(
121
121
  "%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)",
@@ -127,23 +127,23 @@ function Ce() {
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function R() {
130
+ function k() {
131
131
  var e = r(this.type);
132
132
  return B[e] || (B[e] = !0, console.error(
133
133
  "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
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function v(e, s, u, m, P, L) {
136
+ function w(e, s, u, d, P, L) {
137
137
  var f = u.ref;
138
138
  return e = {
139
- $$typeof: p,
139
+ $$typeof: h,
140
140
  type: e,
141
141
  key: s,
142
142
  props: u,
143
- _owner: m
143
+ _owner: d
144
144
  }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
- get: R
146
+ get: k
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
@@ -166,101 +166,101 @@ function Ce() {
166
166
  value: L
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function N(e, s, u, m, P, L) {
169
+ function g(e, s, u, d, P, L) {
170
170
  var f = s.children;
171
171
  if (f !== void 0)
172
- if (m)
172
+ if (d)
173
173
  if (ne(f)) {
174
- for (m = 0; m < f.length; m++)
175
- k(f[m]);
174
+ for (d = 0; d < f.length; d++)
175
+ N(f[d]);
176
176
  Object.freeze && Object.freeze(f);
177
177
  } else
178
178
  console.error(
179
179
  "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
180
  );
181
- else k(f);
181
+ else N(f);
182
182
  if (J.call(s, "key")) {
183
183
  f = r(e);
184
- var _ = Object.keys(s).filter(function(oe) {
184
+ var R = Object.keys(s).filter(function(oe) {
185
185
  return oe !== "key";
186
186
  });
187
- m = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", Z[f + m] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ d = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", Z[f + d] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
- m,
194
+ d,
195
195
  f,
196
- _,
196
+ R,
197
197
  f
198
- ), Z[f + m] = !0);
198
+ ), Z[f + d] = !0);
199
199
  }
200
- if (f = null, u !== void 0 && (c(u), f = "" + u), h(s) && (c(s.key), f = "" + s.key), "key" in s) {
200
+ if (f = null, u !== void 0 && (c(u), f = "" + u), p(s) && (c(s.key), f = "" + s.key), "key" in s) {
201
201
  u = {};
202
202
  for (var W in s)
203
203
  W !== "key" && (u[W] = s[W]);
204
204
  } else u = s;
205
- return f && g(
205
+ return f && y(
206
206
  u,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), v(
208
+ ), w(
209
209
  e,
210
210
  f,
211
211
  u,
212
- o(),
212
+ l(),
213
213
  P,
214
214
  L
215
215
  );
216
216
  }
217
- function k(e) {
218
- w(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === I && (e._payload.status === "fulfilled" ? w(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
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));
219
219
  }
220
- function w(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === p;
220
+ function _(e) {
221
+ return typeof e == "object" && e !== null && e.$$typeof === h;
222
222
  }
223
- var E = le, p = /* @__PURE__ */ Symbol.for("react.transitional.element"), M = /* @__PURE__ */ Symbol.for("react.portal"), C = /* @__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"), l = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), T = /* @__PURE__ */ Symbol.for("react.suspense_list"), te = /* @__PURE__ */ Symbol.for("react.memo"), I = /* @__PURE__ */ Symbol.for("react.lazy"), ae = /* @__PURE__ */ Symbol.for("react.activity"), se = /* @__PURE__ */ Symbol.for("react.client.reference"), z = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ne = Array.isArray, q = console.createTask ? console.createTask : function() {
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() {
224
224
  return null;
225
225
  };
226
- E = {
226
+ j = {
227
227
  react_stack_bottom_frame: function(e) {
228
228
  return e();
229
229
  }
230
230
  };
231
- var V, B = {}, G = E.react_stack_bottom_frame.bind(
232
- E,
231
+ var V, B = {}, G = j.react_stack_bottom_frame.bind(
232
+ j,
233
233
  n
234
234
  )(), X = q(i(n)), Z = {};
235
- O.Fragment = C, O.jsx = function(e, s, u) {
236
- var m = 1e4 > z.recentlyCreatedOwnerStacks++;
237
- return N(
235
+ S.Fragment = v, S.jsx = function(e, s, u) {
236
+ var d = 1e4 > I.recentlyCreatedOwnerStacks++;
237
+ return g(
238
238
  e,
239
239
  s,
240
240
  u,
241
241
  !1,
242
- m ? Error("react-stack-top-frame") : G,
243
- m ? q(i(e)) : X
242
+ d ? Error("react-stack-top-frame") : G,
243
+ d ? q(i(e)) : X
244
244
  );
245
- }, O.jsxs = function(e, s, u) {
246
- var m = 1e4 > z.recentlyCreatedOwnerStacks++;
247
- return N(
245
+ }, S.jsxs = function(e, s, u) {
246
+ var d = 1e4 > I.recentlyCreatedOwnerStacks++;
247
+ return g(
248
248
  e,
249
249
  s,
250
250
  u,
251
251
  !0,
252
- m ? Error("react-stack-top-frame") : G,
253
- m ? q(i(e)) : X
252
+ d ? Error("react-stack-top-frame") : G,
253
+ d ? q(i(e)) : X
254
254
  );
255
255
  };
256
- })()), O;
256
+ })()), S;
257
257
  }
258
258
  var K;
259
- function Te() {
260
- return K || (K = 1, process.env.NODE_ENV === "production" ? A.exports = ve() : A.exports = Ce()), A.exports;
259
+ function we() {
260
+ return K || (K = 1, process.env.NODE_ENV === "production" ? A.exports = Re() : A.exports = ke()), A.exports;
261
261
  }
262
- var t = Te();
263
- const y = {
262
+ var t = we();
263
+ const E = {
264
264
  // Basic operations
265
265
  add: (r, a) => r + a,
266
266
  subtract: (r, a) => r - a,
@@ -294,98 +294,98 @@ const y = {
294
294
  // Evaluate expression
295
295
  evaluate: (r) => {
296
296
  const a = [], c = [];
297
- for (r.forEach((o) => {
298
- if (!y.isOperator(o))
299
- a.push(parseFloat(o));
297
+ for (r.forEach((l) => {
298
+ if (!E.isOperator(l))
299
+ a.push(parseFloat(l));
300
300
  else {
301
- for (; c.length > 0 && y.isOperator(c[c.length - 1]) && y.getPrecedence(c[c.length - 1]) >= y.getPrecedence(o); )
301
+ for (; c.length > 0 && E.isOperator(c[c.length - 1]) && E.getPrecedence(c[c.length - 1]) >= E.getPrecedence(l); )
302
302
  a.push(c.pop());
303
- c.push(o);
303
+ c.push(l);
304
304
  }
305
305
  }); c.length > 0; )
306
306
  a.push(c.pop());
307
307
  const i = [];
308
- return a.forEach((o) => {
309
- if (!y.isOperator(o))
310
- i.push(o);
308
+ return a.forEach((l) => {
309
+ if (!E.isOperator(l))
310
+ i.push(l);
311
311
  else {
312
- const n = i.pop(), h = i.pop();
313
- switch (o) {
312
+ const n = i.pop(), p = i.pop();
313
+ switch (l) {
314
314
  case "+":
315
- i.push(h + n);
315
+ i.push(p + n);
316
316
  break;
317
317
  case "-":
318
- i.push(h - n);
318
+ i.push(p - n);
319
319
  break;
320
320
  case "×":
321
- i.push(h * n);
321
+ i.push(p * n);
322
322
  break;
323
323
  case "÷":
324
- i.push(n !== 0 ? h / n : "Error");
324
+ i.push(n !== 0 ? p / n : "Error");
325
325
  break;
326
326
  }
327
327
  }
328
328
  }), i[0];
329
329
  }
330
- }, Se = () => {
331
- const [r, a] = j("0"), [c, i] = j([]), [o, n] = j(!0), [h, g] = j(0), R = b((l) => {
332
- a((x) => o || x === "0" || x === "Error" ? (n(!1), l) : x.length < 12 ? x + l : x);
333
- }, [o]), v = b(() => {
334
- a((l) => o || l === "0" || l === "Error" ? (n(!1), "0.") : !l.includes(".") && l.length < 12 ? l + "." : l);
335
- }, [o]), N = b((l) => {
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
336
  i((x) => {
337
- const T = [...x];
338
- return r !== "Error" && T.push(r), T.push(l), T;
337
+ const C = [...x];
338
+ return r !== "Error" && C.push(r), C.push(o), C;
339
339
  }), n(!0);
340
- }, [r]), k = b(() => {
340
+ }, [r]), N = b(() => {
341
341
  if (r !== "Error") {
342
- const l = [...c, r], x = y.evaluate(l);
343
- a(y.formatNumber(x)), i([]), n(!0);
342
+ const o = [...c, r], x = E.evaluate(o);
343
+ a(E.formatNumber(x)), i([]), n(!0);
344
344
  }
345
- }, [r, c]), w = b(() => {
345
+ }, [r, c]), _ = b(() => {
346
346
  a("0"), i([]), n(!0);
347
- }, []), E = b(() => {
347
+ }, []), j = b(() => {
348
348
  a("0"), n(!0);
349
- }, []), p = b(() => {
350
- a((l) => l.length > 1 && l !== "Error" ? l.slice(0, -1) : "0");
349
+ }, []), h = b(() => {
350
+ a((o) => o.length > 1 && o !== "Error" ? o.slice(0, -1) : "0");
351
351
  }, []), M = b(() => {
352
- a((l) => {
353
- if (l !== "Error") {
354
- const x = y.percentage(parseFloat(l));
355
- return y.formatNumber(x);
352
+ a((o) => {
353
+ if (o !== "Error") {
354
+ const x = E.percentage(parseFloat(o));
355
+ return E.formatNumber(x);
356
356
  }
357
- return l;
357
+ return o;
358
358
  });
359
- }, []), C = b(() => {
360
- a((l) => {
361
- if (l !== "Error" && l !== "0") {
362
- const x = y.toggleSign(parseFloat(l));
363
- return y.formatNumber(x);
359
+ }, []), v = b(() => {
360
+ a((o) => {
361
+ if (o !== "Error" && o !== "0") {
362
+ const x = E.toggleSign(parseFloat(o));
363
+ return E.formatNumber(x);
364
364
  }
365
- return l;
365
+ return o;
366
366
  });
367
367
  }, []), D = b(() => {
368
- r !== "Error" && (g((l) => l + parseFloat(r)), n(!0));
368
+ r !== "Error" && (y((o) => o + parseFloat(r)), n(!0));
369
369
  }, [r]), $ = b(() => {
370
- r !== "Error" && (g((l) => l - parseFloat(r)), n(!0));
370
+ r !== "Error" && (y((o) => o - parseFloat(r)), n(!0));
371
371
  }, [r]), F = b(() => {
372
- a(y.formatNumber(h)), n(!0);
373
- }, [h]), Y = b(() => {
374
- g(0);
372
+ a(E.formatNumber(p)), n(!0);
373
+ }, [p]), Y = b(() => {
374
+ y(0);
375
375
  }, []);
376
376
  return {
377
377
  display: r,
378
378
  expression: c,
379
- memory: h,
380
- handleNumber: R,
381
- handleDecimal: v,
382
- handleOperator: N,
383
- handleEquals: k,
384
- handleClear: w,
385
- handleClearEntry: E,
386
- handleBackspace: p,
379
+ memory: p,
380
+ handleNumber: k,
381
+ handleDecimal: w,
382
+ handleOperator: g,
383
+ handleEquals: N,
384
+ handleClear: _,
385
+ handleClearEntry: j,
386
+ handleBackspace: h,
387
387
  handlePercentage: M,
388
- handleToggleSign: C,
388
+ handleToggleSign: v,
389
389
  handleMemoryAdd: D,
390
390
  handleMemorySubtract: $,
391
391
  handleMemoryRecall: F,
@@ -396,9 +396,9 @@ const y = {
396
396
  expression: a,
397
397
  memory: c
398
398
  }) => {
399
- const [i, o] = j(/* @__PURE__ */ new Date());
399
+ const [i, l] = O(/* @__PURE__ */ new Date());
400
400
  return ce(() => {
401
- const n = setInterval(() => o(/* @__PURE__ */ new Date()), 1e3);
401
+ const n = setInterval(() => l(/* @__PURE__ */ new Date()), 1e3);
402
402
  return () => clearInterval(n);
403
403
  }, []), /* @__PURE__ */ t.jsxs("div", { className: "bg-card rounded-xl p-6 shadow-inner border border-custom", children: [
404
404
  /* @__PURE__ */ t.jsxs("div", { className: "flex justify-between items-center mb-4 text-sm text-secondary", children: [
@@ -420,24 +420,24 @@ const y = {
420
420
  a.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "text-right text-sm text-secondary mb-2 font-mono", children: a.join(" ") }),
421
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
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(de, { className: "w-3 h-3" }),
423
+ /* @__PURE__ */ t.jsx(me, { className: "w-3 h-3" }),
424
424
  /* @__PURE__ */ t.jsx("span", { className: "font-mono", children: r !== "Error" ? parseInt(r).toString(2).slice(0, 16) : "ERROR" })
425
425
  ] }) })
426
426
  ] });
427
427
  });
428
428
  ee.displayName = "Display";
429
- const d = U(({
429
+ const m = U(({
430
430
  children: r,
431
431
  onClick: a,
432
432
  type: c = "number",
433
433
  size: i = "normal",
434
- className: o = ""
434
+ className: l = ""
435
435
  }) => {
436
436
  const n = {
437
437
  small: "px-3 py-2 text-sm",
438
438
  normal: "px-4 py-3 text-base",
439
439
  large: "px-6 py-4 text-lg"
440
- }, h = {
440
+ }, p = {
441
441
  number: "bg-button-number text-primary",
442
442
  operator: "bg-button-operator text-white",
443
443
  function: "bg-button-function text-primary",
@@ -450,82 +450,61 @@ const d = U(({
450
450
  onClick: a,
451
451
  className: `
452
452
  ${n[i]}
453
- ${h[c]}
453
+ ${p[c]}
454
454
  rounded-lg font-semibold transition-all duration-200
455
455
  active:scale-95 shadow-sm hover:shadow-md
456
- ${o}
456
+ ${l}
457
457
  `,
458
458
  children: r
459
459
  }
460
460
  );
461
461
  });
462
- d.displayName = "Button";
462
+ m.displayName = "Button";
463
463
  const re = U(({
464
464
  onNumber: r,
465
465
  onDecimal: a,
466
466
  onOperator: c,
467
467
  onEquals: i,
468
- onClear: o,
468
+ onClear: l,
469
469
  onClearEntry: n,
470
- onBackspace: h,
471
- onPercentage: g,
472
- onToggleSign: R,
473
- onMemoryAdd: v,
474
- onMemorySubtract: N,
475
- onMemoryRecall: k,
476
- onMemoryClear: w
470
+ onBackspace: p,
471
+ onPercentage: y,
472
+ onToggleSign: k,
473
+ onMemoryAdd: w,
474
+ onMemorySubtract: g,
475
+ onMemoryRecall: N,
476
+ onMemoryClear: _
477
477
  }) => {
478
- const E = [7, 8, 9, 4, 5, 6, 1, 2, 3, 0];
478
+ const j = [7, 8, 9, 4, 5, 6, 1, 2, 3, 0];
479
479
  return /* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-5 gap-2", children: [
480
- /* @__PURE__ */ t.jsx(d, { type: "memory", onClick: v, size: "small", children: /* @__PURE__ */ t.jsx(me, { className: "w-4 h-4" }) }),
481
- /* @__PURE__ */ t.jsx(d, { type: "memory", onClick: N, size: "small", children: /* @__PURE__ */ t.jsx(fe, { className: "w-4 h-4" }) }),
482
- /* @__PURE__ */ t.jsx(d, { type: "memory", onClick: k, size: "small", children: /* @__PURE__ */ t.jsx(he, { className: "w-4 h-4" }) }),
483
- /* @__PURE__ */ t.jsx(d, { type: "memory", onClick: w, size: "small", children: /* @__PURE__ */ t.jsx(pe, { className: "w-4 h-4" }) }),
484
- /* @__PURE__ */ t.jsx(d, { type: "function", onClick: n, size: "small", children: "CE" }),
485
- /* @__PURE__ */ t.jsx(d, { type: "function", onClick: R, size: "small", children: "±" }),
486
- /* @__PURE__ */ t.jsx(d, { type: "function", onClick: g, size: "small", children: /* @__PURE__ */ t.jsx(xe, { className: "w-4 h-4" }) }),
487
- /* @__PURE__ */ t.jsx(d, { type: "function", onClick: o, size: "small", children: /* @__PURE__ */ t.jsx(be, { className: "w-4 h-4" }) }),
488
- /* @__PURE__ */ t.jsxs(d, { type: "function", onClick: h, size: "small", children: [
489
- /* @__PURE__ */ t.jsx(ye, { className: "w-4 h-4" }),
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
490
  " "
491
491
  ] }),
492
- /* @__PURE__ */ t.jsx(d, { type: "operator", onClick: () => c("÷"), size: "small", children: /* @__PURE__ */ t.jsx(ge, { className: "w-4 h-4" }) }),
493
- E.slice(0, 3).map((p) => /* @__PURE__ */ t.jsx(d, { onClick: () => r(p.toString()), children: p }, p)),
494
- /* @__PURE__ */ t.jsx(d, { type: "operator", onClick: () => c("×"), children: /* @__PURE__ */ t.jsx(Ee, { className: "w-4 h-4" }) }),
495
- E.slice(3, 6).map((p) => /* @__PURE__ */ t.jsx(d, { onClick: () => r(p.toString()), children: p }, p)),
496
- /* @__PURE__ */ t.jsx(d, { type: "operator", onClick: () => c("-"), children: /* @__PURE__ */ t.jsx(je, { className: "w-4 h-4" }) }),
497
- E.slice(6, 9).map((p) => /* @__PURE__ */ t.jsx(d, { onClick: () => r(p.toString()), children: p }, p)),
498
- /* @__PURE__ */ t.jsx(d, { type: "operator", onClick: () => c("+"), children: /* @__PURE__ */ t.jsx(Ne, { className: "w-4 h-4" }) }),
499
- /* @__PURE__ */ t.jsx(d, { type: "number", onClick: a, className: "col-span-2", children: "." }),
500
- /* @__PURE__ */ t.jsx(d, { type: "number", onClick: () => r("0"), className: "col-span-2", children: "0" }),
501
- /* @__PURE__ */ t.jsx(d, { type: "equals", onClick: i, className: "col-span-1", children: /* @__PURE__ */ t.jsx(ke, { className: "w-5 h-5" }) })
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
502
  ] });
503
503
  });
504
504
  re.displayName = "Keypad";
505
- const Ae = () => {
506
- const r = Se(), [a, c] = j("light"), i = () => {
507
- c((n) => n === "light" ? "dark" : n === "dark" ? "ocean" : "light"), document.body.className = `theme-${a === "light" ? "dark" : a === "dark" ? "ocean" : "light"}`;
508
- };
509
- j(() => {
510
- document.body.className = "theme-light";
511
- }, []);
512
- const o = {
513
- light: /* @__PURE__ */ t.jsx(Re, { className: "w-5 h-5 text-yellow-500" }),
514
- dark: /* @__PURE__ */ t.jsx(_e, { className: "w-5 h-5 text-blue-400" }),
515
- ocean: /* @__PURE__ */ t.jsx(we, { className: "w-5 h-5 text-cyan-400" })
516
- };
517
- return /* @__PURE__ */ t.jsx("div", { className: "min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4 transition-colors duration-300", children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-md w-full bg-card rounded-2xl shadow-2xl p-6 border border-custom", children: [
518
- /* @__PURE__ */ t.jsxs("div", { className: "flex justify-between items-center mb-4", children: [
519
- /* @__PURE__ */ t.jsx("h1", { className: "text-2xl font-bold text-primary", children: "Calculator" }),
520
- /* @__PURE__ */ t.jsx(
521
- "button",
522
- {
523
- onClick: i,
524
- className: "p-2 rounded-lg bg-card border border-custom hover:opacity-80 transition-opacity",
525
- children: o[a]
526
- }
527
- )
528
- ] }),
505
+ const Se = () => {
506
+ const r = ve();
507
+ return /* @__PURE__ */ t.jsxs("div", { className: "max-w-md w-full mx-auto p-4", children: [
529
508
  /* @__PURE__ */ t.jsx(
530
509
  ee,
531
510
  {
@@ -553,12 +532,15 @@ const Ae = () => {
553
532
  }
554
533
  ) }),
555
534
  /* @__PURE__ */ t.jsx("div", { className: "mt-4 text-xs text-center text-secondary", children: /* @__PURE__ */ t.jsxs("p", { children: [
556
- "Standalone Calculator App | Memory: ",
535
+ "Memory: ",
557
536
  r.memory
558
537
  ] }) })
559
- ] }) });
538
+ ] });
560
539
  };
561
540
  export {
562
- Ae as Calculator,
563
- Se as useCalculator
541
+ m as Button,
542
+ Se as Calculator,
543
+ ee as Display,
544
+ re as Keypad,
545
+ ve as useCalculator
564
546
  };
package/dist/index.umd.js CHANGED
@@ -1,12 +1,12 @@
1
- (function(k,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):(k=typeof globalThis<"u"?globalThis:k||self,i(k.CalculatorModule={},k.React,k.LucideReact))})(this,(function(k,i,p){"use strict";var A={exports:{}},v={};var B;function ae(){if(B)return v;B=1;var r=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function c(u,l,n){var x=null;if(n!==void 0&&(x=""+n),l.key!==void 0&&(x=""+l.key),"key"in l){n={};for(var g in l)g!=="key"&&(n[g]=l[g])}else n=l;return l=n.ref,{$$typeof:r,type:u,key:x,ref:l!==void 0?l:null,props:n}}return v.Fragment=a,v.jsx=c,v.jsxs=c,v}var T={};var G;function se(){return G||(G=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 Y:return"Profiler";case F: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 D:return"Portal";case z:return e.displayName||"Context";case I:return(e._context.displayName||"Context")+".Consumer";case o: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 L: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===L)return"<...>";try{var s=r(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function l(){var e=W.A;return e===null?null:e.getOwner()}function n(){return Error("react-stack-top-frame")}function x(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 S(){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 R(e,s,m,f,M,J){var h=m.ref;return e={$$typeof:b,type:e,key:s,props:m,_owner:f},(h!==void 0?h:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:S}):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:J}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function N(e,s,m,f,M,J){var h=s.children;if(h!==void 0)if(f)if(ue(h)){for(f=0;f<h.length;f++)C(h[f]);Object.freeze&&Object.freeze(h)}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 C(h);if(K.call(s,"key")){h=r(e);var _=Object.keys(s).filter(function(me){return me!=="key"});f=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",te[h+f]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
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:
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,h,_,h),te[h+f]=!0)}if(h=null,m!==void 0&&(c(m),h=""+m),x(s)&&(c(s.key),h=""+s.key),"key"in s){m={};for(var V in s)V!=="key"&&(m[V]=s[V])}else m=s;return h&&g(m,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,h,m,l(),M,J)}function C(e){w(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===L&&(e._payload.status==="fulfilled"?w(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function w(e){return typeof e=="object"&&e!==null&&e.$$typeof===b}var E=i,b=Symbol.for("react.transitional.element"),D=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),z=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),ce=Symbol.for("react.activity"),ie=Symbol.for("react.client.reference"),W=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=Object.prototype.hasOwnProperty,ue=Array.isArray,U=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var q,$={},ee=E.react_stack_bottom_frame.bind(E,n)(),re=U(u(n)),te={};T.Fragment=O,T.jsx=function(e,s,m){var f=1e4>W.recentlyCreatedOwnerStacks++;return N(e,s,m,!1,f?Error("react-stack-top-frame"):ee,f?U(u(e)):re)},T.jsxs=function(e,s,m){var f=1e4>W.recentlyCreatedOwnerStacks++;return N(e,s,m,!0,f?Error("react-stack-top-frame"):ee,f?U(u(e)):re)}})()),T}var X;function ne(){return X||(X=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(l=>{if(!j.isOperator(l))a.push(parseFloat(l));else{for(;c.length>0&&j.isOperator(c[c.length-1])&&j.getPrecedence(c[c.length-1])>=j.getPrecedence(l);)a.push(c.pop());c.push(l)}});c.length>0;)a.push(c.pop());const u=[];return a.forEach(l=>{if(!j.isOperator(l))u.push(l);else{const n=u.pop(),x=u.pop();switch(l){case"+":u.push(x+n);break;case"-":u.push(x-n);break;case"×":u.push(x*n);break;case"÷":u.push(n!==0?x/n:"Error");break}}}),u[0]}},Z=()=>{const[r,a]=i.useState("0"),[c,u]=i.useState([]),[l,n]=i.useState(!0),[x,g]=i.useState(0),S=i.useCallback(o=>{a(y=>l||y==="0"||y==="Error"?(n(!1),o):y.length<12?y+o:y)},[l]),R=i.useCallback(()=>{a(o=>l||o==="0"||o==="Error"?(n(!1),"0."):!o.includes(".")&&o.length<12?o+".":o)},[l]),N=i.useCallback(o=>{u(y=>{const P=[...y];return r!=="Error"&&P.push(r),P.push(o),P}),n(!0)},[r]),C=i.useCallback(()=>{if(r!=="Error"){const o=[...c,r],y=j.evaluate(o);a(j.formatNumber(y)),u([]),n(!0)}},[r,c]),w=i.useCallback(()=>{a("0"),u([]),n(!0)},[]),E=i.useCallback(()=>{a("0"),n(!0)},[]),b=i.useCallback(()=>{a(o=>o.length>1&&o!=="Error"?o.slice(0,-1):"0")},[]),D=i.useCallback(()=>{a(o=>{if(o!=="Error"){const y=j.percentage(parseFloat(o));return j.formatNumber(y)}return o})},[]),O=i.useCallback(()=>{a(o=>{if(o!=="Error"&&o!=="0"){const y=j.toggleSign(parseFloat(o));return j.formatNumber(y)}return o})},[]),F=i.useCallback(()=>{r!=="Error"&&(g(o=>o+parseFloat(r)),n(!0))},[r]),Y=i.useCallback(()=>{r!=="Error"&&(g(o=>o-parseFloat(r)),n(!0))},[r]),I=i.useCallback(()=>{a(j.formatNumber(x)),n(!0)},[x]),z=i.useCallback(()=>{g(0)},[]);return{display:r,expression:c,memory:x,handleNumber:S,handleDecimal:R,handleOperator:N,handleEquals:C,handleClear:w,handleClearEntry:E,handleBackspace:b,handlePercentage:D,handleToggleSign:O,handleMemoryAdd:F,handleMemorySubtract:Y,handleMemoryRecall:I,handleMemoryClear:z}},H=i.memo(({value:r,expression:a,memory:c})=>{const[u,l]=i.useState(new Date);return i.useEffect(()=>{const n=setInterval(()=>l(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(p.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(p.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(p.Zap,{className:"w-3 h-3"}),t.jsx("span",{className:"font-mono",children:r!=="Error"?parseInt(r).toString(2).slice(0,16):"ERROR"})]})})]})});H.displayName="Display";const d=i.memo(({children:r,onClick:a,type:c="number",size:u="normal",className:l=""})=>{const n={small:"px-3 py-2 text-sm",normal:"px-4 py-3 text-base",large:"px-6 py-4 text-lg"},x={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:`
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
7
  ${n[u]}
8
- ${x[c]}
8
+ ${h[c]}
9
9
  rounded-lg font-semibold transition-all duration-200
10
10
  active:scale-95 shadow-sm hover:shadow-md
11
- ${l}
12
- `,children:r})});d.displayName="Button";const Q=i.memo(({onNumber:r,onDecimal:a,onOperator:c,onEquals:u,onClear:l,onClearEntry:n,onBackspace:x,onPercentage:g,onToggleSign:S,onMemoryAdd:R,onMemorySubtract:N,onMemoryRecall:C,onMemoryClear:w})=>{const E=[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:R,size:"small",children:t.jsx(p.PlusCircle,{className:"w-4 h-4"})}),t.jsx(d,{type:"memory",onClick:N,size:"small",children:t.jsx(p.MinusCircle,{className:"w-4 h-4"})}),t.jsx(d,{type:"memory",onClick:C,size:"small",children:t.jsx(p.RotateCw,{className:"w-4 h-4"})}),t.jsx(d,{type:"memory",onClick:w,size:"small",children:t.jsx(p.Trash2,{className:"w-4 h-4"})}),t.jsx(d,{type:"function",onClick:n,size:"small",children:"CE"}),t.jsx(d,{type:"function",onClick:S,size:"small",children:"±"}),t.jsx(d,{type:"function",onClick:g,size:"small",children:t.jsx(p.Percent,{className:"w-4 h-4"})}),t.jsx(d,{type:"function",onClick:l,size:"small",children:t.jsx(p.RotateCcw,{className:"w-4 h-4"})}),t.jsxs(d,{type:"function",onClick:x,size:"small",children:[t.jsx(p.Delete,{className:"w-4 h-4"})," "]}),t.jsx(d,{type:"operator",onClick:()=>c("÷"),size:"small",children:t.jsx(p.Divide,{className:"w-4 h-4"})}),E.slice(0,3).map(b=>t.jsx(d,{onClick:()=>r(b.toString()),children:b},b)),t.jsx(d,{type:"operator",onClick:()=>c("×"),children:t.jsx(p.X,{className:"w-4 h-4"})}),E.slice(3,6).map(b=>t.jsx(d,{onClick:()=>r(b.toString()),children:b},b)),t.jsx(d,{type:"operator",onClick:()=>c("-"),children:t.jsx(p.Minus,{className:"w-4 h-4"})}),E.slice(6,9).map(b=>t.jsx(d,{onClick:()=>r(b.toString()),children:b},b)),t.jsx(d,{type:"operator",onClick:()=>c("+"),children:t.jsx(p.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(p.Equal,{className:"w-5 h-5"})})]})});Q.displayName="Keypad";const le=()=>{const r=Z(),[a,c]=i.useState("light"),u=()=>{c(n=>n==="light"?"dark":n==="dark"?"ocean":"light"),document.body.className=`theme-${a==="light"?"dark":a==="dark"?"ocean":"light"}`};i.useState(()=>{document.body.className="theme-light"},[]);const l={light:t.jsx(p.Sun,{className:"w-5 h-5 text-yellow-500"}),dark:t.jsx(p.Moon,{className:"w-5 h-5 text-blue-400"}),ocean:t.jsx(p.Cloud,{className:"w-5 h-5 text-cyan-400"})};return t.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4 transition-colors duration-300",children:t.jsxs("div",{className:"max-w-md w-full bg-card rounded-2xl shadow-2xl p-6 border border-custom",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h1",{className:"text-2xl font-bold text-primary",children:"Calculator"}),t.jsx("button",{onClick:u,className:"p-2 rounded-lg bg-card border border-custom hover:opacity-80 transition-opacity",children:l[a]})]}),t.jsx(H,{value:r.display,expression:r.expression,memory:r.memory}),t.jsx("div",{className:"mt-6",children:t.jsx(Q,{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:["Standalone Calculator App | Memory: ",r.memory]})})]})})};k.Calculator=le,k.useCalculator=Z,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
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"})}));
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
+
1
2
  {
2
3
  "name": "@birimengo/calculator",
3
- "version": "1.0.0",
4
- "description": "A beautiful calculator component with memory functions and multiple themes",
4
+ "version": "1.0.2",
5
+ "description": "A beautiful calculator component with memory functions",
5
6
  "main": "dist/index.js",
6
- "module": "dist/index.esm.js",
7
+ "module": "dist/index.es.js",
7
8
  "unpkg": "dist/index.umd.js",
8
9
  "types": "dist/index.d.ts",
9
10
  "files": [