@askrjs/askr 0.0.7 → 0.0.8

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.
@@ -1,4 +1,4 @@
1
- import { P as Props, J as JSXElement } from './jsx-AzPM8gMS.js';
1
+ import { P as Props, J as JSXElement } from './jsx-CSWf4VFg.js';
2
2
 
3
3
  /**
4
4
  * State primitive for Askr components
@@ -1,7 +1,7 @@
1
1
  export { L as LayoutComponent, l as layout } from '../layout-BINPv-nz.js';
2
- import '../types-uOPfcrdz.js';
3
- import { J as JSXElement } from '../jsx-AzPM8gMS.js';
4
- import { S as State } from '../component-BBGWJdqJ.js';
2
+ import '../types-DxdosFWx.js';
3
+ import { J as JSXElement } from '../jsx-CSWf4VFg.js';
4
+ import { S as State } from '../component-DHAn9JxU.js';
5
5
 
6
6
  type SlotProps = {
7
7
  asChild: true;
@@ -21,6 +21,7 @@ type SlotProps = {
21
21
  * 1. asChild Pattern
22
22
  * When asChild=true, merges props into the single child element.
23
23
  * Child must be a valid JSXElement; non-element children return null.
24
+ * **Slot props override child props** (injection pattern).
24
25
  *
25
26
  * 2. Fallback Behavior
26
27
  * When asChild=false, returns a Fragment (structural no-op).
@@ -1,6 +1,9 @@
1
1
  // src/foundations/structures/layout.tsx
2
2
  function layout(Layout) {
3
- return (children, props) => Layout({ ...props, children });
3
+ return (children, props) => {
4
+ const mergedProps = { ...props, children };
5
+ return Layout(mergedProps);
6
+ };
4
7
  }
5
8
 
6
9
  // src/common/jsx.ts
@@ -100,17 +103,22 @@ function isDefaultPrevented(value) {
100
103
  return typeof value === "object" && value !== null && "defaultPrevented" in value && value.defaultPrevented === true;
101
104
  }
102
105
  function composeHandlers(first, second, options) {
106
+ if (!first && !second) {
107
+ return noop;
108
+ }
109
+ if (!first) return second;
110
+ if (!second) return first;
103
111
  const checkDefaultPrevented = options?.checkDefaultPrevented !== false;
104
112
  return function composed(...args) {
105
- if (typeof first === "function") first(...args);
106
- if (checkDefaultPrevented) {
107
- if (isDefaultPrevented(args[0])) {
108
- return;
109
- }
113
+ first(...args);
114
+ if (checkDefaultPrevented && isDefaultPrevented(args[0])) {
115
+ return;
110
116
  }
111
- if (typeof second === "function") second(...args);
117
+ second(...args);
112
118
  };
113
119
  }
120
+ function noop() {
121
+ }
114
122
 
115
123
  // src/foundations/utilities/mergeProps.ts
116
124
  function isEventHandlerKey(key) {
@@ -982,7 +990,11 @@ function pressable({
982
990
  props.role = "button";
983
991
  props.tabIndex = disabled ? -1 : 0;
984
992
  props.onKeyDown = (e) => {
985
- if (disabled) return;
993
+ if (disabled) {
994
+ e.preventDefault?.();
995
+ e.stopPropagation?.();
996
+ return;
997
+ }
986
998
  if (e.key === "Enter") {
987
999
  e.preventDefault?.();
988
1000
  onPress?.(e);
@@ -993,7 +1005,11 @@ function pressable({
993
1005
  }
994
1006
  };
995
1007
  props.onKeyUp = (e) => {
996
- if (disabled) return;
1008
+ if (disabled) {
1009
+ e.preventDefault?.();
1010
+ e.stopPropagation?.();
1011
+ return;
1012
+ }
997
1013
  if (e.key === " ") {
998
1014
  e.preventDefault?.();
999
1015
  onPress?.(e);
@@ -1009,12 +1025,18 @@ function dismissable({ onDismiss, disabled }) {
1009
1025
  // Prop for the component root to handle Escape
1010
1026
  onKeyDown: disabled ? void 0 : (e) => {
1011
1027
  if (e.key === "Escape") {
1028
+ e.preventDefault?.();
1029
+ e.stopPropagation?.();
1012
1030
  onDismiss?.();
1013
1031
  }
1014
1032
  },
1015
1033
  // Factory: runtime should attach this listener at the appropriate scope.
1016
1034
  outsideListener: disabled ? void 0 : (isInside) => (e) => {
1017
- if (!isInside(e.target)) onDismiss?.();
1035
+ if (!isInside(e.target)) {
1036
+ e.preventDefault?.();
1037
+ e.stopPropagation?.();
1038
+ onDismiss?.();
1039
+ }
1018
1040
  }
1019
1041
  };
1020
1042
  }