@akashjs/runtime 0.1.0 → 0.1.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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @akashjs/runtime
2
+
3
+ AkashJS core runtime — signals, components, DOM rendering
4
+
5
+ Part of the [AkashJS](https://github.com/phpirate/akashjs) framework.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @akashjs/runtime
11
+ ```
12
+
13
+ ## Documentation
14
+
15
+ - [Guide](https://akash.js.org/guide/introduction)
16
+ - [API Reference](https://akash.js.org/api/runtime)
17
+ - [GitHub](https://github.com/phpirate/akashjs)
18
+
19
+ ## License
20
+
21
+ MIT
package/dist/index.cjs CHANGED
@@ -1413,10 +1413,6 @@ function useToggle(initial = false) {
1413
1413
  };
1414
1414
  }
1415
1415
  function usePrevious(source) {
1416
- signal(void 0);
1417
- effect(() => {
1418
- source();
1419
- });
1420
1416
  let lastValue;
1421
1417
  const tracked = signal(void 0);
1422
1418
  effect(() => {
@@ -1579,6 +1575,55 @@ function useWindowSize() {
1579
1575
  height: (() => height())
1580
1576
  };
1581
1577
  }
1578
+ function useClickOutside(target, handler, options = {}) {
1579
+ if (typeof document === "undefined") return () => {
1580
+ };
1581
+ const {
1582
+ events = ["pointerdown"],
1583
+ ignore = [],
1584
+ active = true
1585
+ } = options;
1586
+ let isActive = active;
1587
+ function getTarget() {
1588
+ return typeof target === "function" ? target() : target;
1589
+ }
1590
+ function shouldIgnore(event) {
1591
+ const eventTarget = event.target;
1592
+ if (!eventTarget) return false;
1593
+ for (const pattern of ignore) {
1594
+ if (typeof pattern === "string") {
1595
+ if (eventTarget.closest(pattern)) return true;
1596
+ } else {
1597
+ if (pattern === eventTarget || pattern.contains(eventTarget)) return true;
1598
+ }
1599
+ }
1600
+ return false;
1601
+ }
1602
+ function listener(event) {
1603
+ if (!isActive) return;
1604
+ const el = getTarget();
1605
+ if (!el) return;
1606
+ const eventTarget = event.target;
1607
+ if (el === eventTarget || el.contains(eventTarget)) return;
1608
+ if (shouldIgnore(event)) return;
1609
+ handler(event);
1610
+ }
1611
+ for (const eventName of events) {
1612
+ document.addEventListener(eventName, listener, { passive: true, capture: true });
1613
+ }
1614
+ const dispose = () => {
1615
+ for (const eventName of events) {
1616
+ document.removeEventListener(eventName, listener, { capture: true });
1617
+ }
1618
+ };
1619
+ dispose.enable = () => {
1620
+ isActive = true;
1621
+ };
1622
+ dispose.disable = () => {
1623
+ isActive = false;
1624
+ };
1625
+ return dispose;
1626
+ }
1582
1627
 
1583
1628
  // src/portal.ts
1584
1629
  var Portal = defineComponent((ctx) => {
@@ -3956,9 +4001,9 @@ function animateSpring(el, target, options = {}) {
3956
4001
  } = options;
3957
4002
  const current = {};
3958
4003
  const velocity = {};
3959
- const computed5 = window.getComputedStyle(el);
4004
+ const computed4 = window.getComputedStyle(el);
3960
4005
  for (const prop of Object.keys(target)) {
3961
- current[prop] = parseFloat(computed5.getPropertyValue(prop)) || 0;
4006
+ current[prop] = parseFloat(computed4.getPropertyValue(prop)) || 0;
3962
4007
  velocity[prop] = 0;
3963
4008
  }
3964
4009
  let animating = true;
@@ -5390,6 +5435,7 @@ exports.uppercase = uppercase;
5390
5435
  exports.urlToFilePath = urlToFilePath;
5391
5436
  exports.useAnnounce = useAnnounce;
5392
5437
  exports.useBreakpoint = useBreakpoint;
5438
+ exports.useClickOutside = useClickOutside;
5393
5439
  exports.useClipboard = useClipboard;
5394
5440
  exports.useCounter = useCounter;
5395
5441
  exports.useDebounce = useDebounce;