@number10/jsx-components 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/LICENSE +667 -0
  2. package/README.md +43 -0
  3. package/dist/Accordion.cjs +1 -0
  4. package/dist/Accordion.d.ts +43 -0
  5. package/dist/Accordion.d.ts.map +1 -0
  6. package/dist/Accordion.js +71 -0
  7. package/dist/Accordion.test.d.ts +2 -0
  8. package/dist/Accordion.test.d.ts.map +1 -0
  9. package/dist/ActivityIndicator.cjs +1 -0
  10. package/dist/ActivityIndicator.d.ts +21 -0
  11. package/dist/ActivityIndicator.d.ts.map +1 -0
  12. package/dist/ActivityIndicator.js +133 -0
  13. package/dist/AlertDialog.cjs +1 -0
  14. package/dist/AlertDialog.d.ts +53 -0
  15. package/dist/AlertDialog.d.ts.map +1 -0
  16. package/dist/AlertDialog.js +76 -0
  17. package/dist/Badge.cjs +1 -0
  18. package/dist/Badge.d.ts +96 -0
  19. package/dist/Badge.d.ts.map +1 -0
  20. package/dist/Badge.js +238 -0
  21. package/dist/Badge.test.d.ts +2 -0
  22. package/dist/Badge.test.d.ts.map +1 -0
  23. package/dist/BottomSheet.cjs +1 -0
  24. package/dist/BottomSheet.d.ts +72 -0
  25. package/dist/BottomSheet.d.ts.map +1 -0
  26. package/dist/BottomSheet.js +132 -0
  27. package/dist/Button.cjs +1 -0
  28. package/dist/Button.d.ts +61 -0
  29. package/dist/Button.d.ts.map +1 -0
  30. package/dist/Button.js +251 -0
  31. package/dist/Checkbox.cjs +1 -0
  32. package/dist/Checkbox.d.ts +40 -0
  33. package/dist/Checkbox.d.ts.map +1 -0
  34. package/dist/Checkbox.js +84 -0
  35. package/dist/Checkbox.test.d.ts +2 -0
  36. package/dist/Checkbox.test.d.ts.map +1 -0
  37. package/dist/ColorPicker.cjs +1 -0
  38. package/dist/ColorPicker.d.ts +48 -0
  39. package/dist/ColorPicker.d.ts.map +1 -0
  40. package/dist/ColorPicker.js +256 -0
  41. package/dist/DebugPanel.cjs +1 -0
  42. package/dist/DebugPanel.d.ts +63 -0
  43. package/dist/DebugPanel.d.ts.map +1 -0
  44. package/dist/DebugPanel.js +116 -0
  45. package/dist/Dialog.cjs +1 -0
  46. package/dist/Dialog.d.ts +59 -0
  47. package/dist/Dialog.d.ts.map +1 -0
  48. package/dist/Dialog.js +142 -0
  49. package/dist/Divider.cjs +1 -0
  50. package/dist/Divider.d.ts +19 -0
  51. package/dist/Divider.d.ts.map +1 -0
  52. package/dist/Divider.js +15 -0
  53. package/dist/Divider.test.d.ts +2 -0
  54. package/dist/Divider.test.d.ts.map +1 -0
  55. package/dist/Dropdown.cjs +1 -0
  56. package/dist/Dropdown.d.ts +35 -0
  57. package/dist/Dropdown.d.ts.map +1 -0
  58. package/dist/Dropdown.js +222 -0
  59. package/dist/Icon.cjs +1 -0
  60. package/dist/Icon.d.ts +71 -0
  61. package/dist/Icon.d.ts.map +1 -0
  62. package/dist/Icon.js +57 -0
  63. package/dist/Icon.test.d.ts +2 -0
  64. package/dist/Icon.test.d.ts.map +1 -0
  65. package/dist/Image.cjs +1 -0
  66. package/dist/Image.d.ts +10 -0
  67. package/dist/Image.d.ts.map +1 -0
  68. package/dist/Image.js +18 -0
  69. package/dist/Joystick.cjs +1 -0
  70. package/dist/Joystick.d.ts +32 -0
  71. package/dist/Joystick.d.ts.map +1 -0
  72. package/dist/Joystick.js +185 -0
  73. package/dist/ListBox.cjs +1 -0
  74. package/dist/ListBox.d.ts +67 -0
  75. package/dist/ListBox.d.ts.map +1 -0
  76. package/dist/ListBox.js +104 -0
  77. package/dist/ListBox.test.d.ts +2 -0
  78. package/dist/ListBox.test.d.ts.map +1 -0
  79. package/dist/MenuButton.cjs +1 -0
  80. package/dist/MenuButton.d.ts +33 -0
  81. package/dist/MenuButton.d.ts.map +1 -0
  82. package/dist/MenuButton.js +63 -0
  83. package/dist/Modal.cjs +1 -0
  84. package/dist/Modal.d.ts +27 -0
  85. package/dist/Modal.d.ts.map +1 -0
  86. package/dist/Modal.js +174 -0
  87. package/dist/Modal.test.d.ts +2 -0
  88. package/dist/Modal.test.d.ts.map +1 -0
  89. package/dist/NineSlice.cjs +1 -0
  90. package/dist/NineSlice.d.ts +40 -0
  91. package/dist/NineSlice.d.ts.map +1 -0
  92. package/dist/NineSlice.js +314 -0
  93. package/dist/NineSlice.props.test.d.ts +2 -0
  94. package/dist/NineSlice.props.test.d.ts.map +1 -0
  95. package/dist/NineSlice.test.d.ts +2 -0
  96. package/dist/NineSlice.test.d.ts.map +1 -0
  97. package/dist/NineSliceButton.cjs +1 -0
  98. package/dist/NineSliceButton.d.ts +94 -0
  99. package/dist/NineSliceButton.d.ts.map +1 -0
  100. package/dist/NineSliceButton.js +61 -0
  101. package/dist/NineSliceButton.test.d.ts +2 -0
  102. package/dist/NineSliceButton.test.d.ts.map +1 -0
  103. package/dist/NumberInput.cjs +1 -0
  104. package/dist/NumberInput.d.ts +90 -0
  105. package/dist/NumberInput.d.ts.map +1 -0
  106. package/dist/NumberInput.js +222 -0
  107. package/dist/NumberInput.test.d.ts +2 -0
  108. package/dist/NumberInput.test.d.ts.map +1 -0
  109. package/dist/PalettePicker.cjs +1 -0
  110. package/dist/PalettePicker.d.ts +49 -0
  111. package/dist/PalettePicker.d.ts.map +1 -0
  112. package/dist/PalettePicker.js +152 -0
  113. package/dist/PalettePicker.test.d.ts +2 -0
  114. package/dist/PalettePicker.test.d.ts.map +1 -0
  115. package/dist/Popover.cjs +1 -0
  116. package/dist/Popover.d.ts +95 -0
  117. package/dist/Popover.d.ts.map +1 -0
  118. package/dist/Popover.js +267 -0
  119. package/dist/Portal.cjs +1 -0
  120. package/dist/Portal.d.ts +30 -0
  121. package/dist/Portal.d.ts.map +1 -0
  122. package/dist/Portal.js +64 -0
  123. package/dist/Portal.test.d.ts +2 -0
  124. package/dist/Portal.test.d.ts.map +1 -0
  125. package/dist/ProgressBar.cjs +1 -0
  126. package/dist/ProgressBar.d.ts +61 -0
  127. package/dist/ProgressBar.d.ts.map +1 -0
  128. package/dist/ProgressBar.js +80 -0
  129. package/dist/ProgressBar.test.d.ts +2 -0
  130. package/dist/ProgressBar.test.d.ts.map +1 -0
  131. package/dist/ProgressView.cjs +1 -0
  132. package/dist/ProgressView.d.ts +37 -0
  133. package/dist/ProgressView.d.ts.map +1 -0
  134. package/dist/ProgressView.js +71 -0
  135. package/dist/RadioButton.cjs +1 -0
  136. package/dist/RadioButton.d.ts +21 -0
  137. package/dist/RadioButton.d.ts.map +1 -0
  138. package/dist/RadioButton.js +53 -0
  139. package/dist/RadioGroup.cjs +1 -0
  140. package/dist/RadioGroup.d.ts +26 -0
  141. package/dist/RadioGroup.d.ts.map +1 -0
  142. package/dist/RadioGroup.js +32 -0
  143. package/dist/RatingBar.cjs +1 -0
  144. package/dist/RatingBar.d.ts +24 -0
  145. package/dist/RatingBar.d.ts.map +1 -0
  146. package/dist/RatingBar.js +84 -0
  147. package/dist/ScrollSlider.cjs +1 -0
  148. package/dist/ScrollSlider.d.ts +48 -0
  149. package/dist/ScrollSlider.d.ts.map +1 -0
  150. package/dist/ScrollSlider.js +93 -0
  151. package/dist/ScrollView.cjs +1 -0
  152. package/dist/ScrollView.d.ts +121 -0
  153. package/dist/ScrollView.d.ts.map +1 -0
  154. package/dist/ScrollView.js +541 -0
  155. package/dist/ScrollView.test.d.ts +2 -0
  156. package/dist/ScrollView.test.d.ts.map +1 -0
  157. package/dist/SegmentedControl.cjs +1 -0
  158. package/dist/SegmentedControl.d.ts +50 -0
  159. package/dist/SegmentedControl.d.ts.map +1 -0
  160. package/dist/SegmentedControl.js +201 -0
  161. package/dist/SegmentedControl.test.d.ts +2 -0
  162. package/dist/SegmentedControl.test.d.ts.map +1 -0
  163. package/dist/Sidebar.cjs +1 -0
  164. package/dist/Sidebar.d.ts +36 -0
  165. package/dist/Sidebar.d.ts.map +1 -0
  166. package/dist/Sidebar.js +122 -0
  167. package/dist/Slider.cjs +1 -0
  168. package/dist/Slider.d.ts +80 -0
  169. package/dist/Slider.d.ts.map +1 -0
  170. package/dist/Slider.js +233 -0
  171. package/dist/Tabs.cjs +1 -0
  172. package/dist/Tabs.d.ts +23 -0
  173. package/dist/Tabs.d.ts.map +1 -0
  174. package/dist/Tabs.js +101 -0
  175. package/dist/TextInput.cjs +17 -0
  176. package/dist/TextInput.d.ts +82 -0
  177. package/dist/TextInput.d.ts.map +1 -0
  178. package/dist/TextInput.js +441 -0
  179. package/dist/Toast.cjs +1 -0
  180. package/dist/Toast.d.ts +66 -0
  181. package/dist/Toast.d.ts.map +1 -0
  182. package/dist/Toast.js +188 -0
  183. package/dist/Toast.test.d.ts +2 -0
  184. package/dist/Toast.test.d.ts.map +1 -0
  185. package/dist/Toggle.cjs +1 -0
  186. package/dist/Toggle.d.ts +14 -0
  187. package/dist/Toggle.d.ts.map +1 -0
  188. package/dist/Toggle.js +135 -0
  189. package/dist/Toolbar.cjs +1 -0
  190. package/dist/Toolbar.d.ts +129 -0
  191. package/dist/Toolbar.d.ts.map +1 -0
  192. package/dist/Toolbar.js +159 -0
  193. package/dist/Toolbar.test.d.ts +2 -0
  194. package/dist/Toolbar.test.d.ts.map +1 -0
  195. package/dist/TransformOriginView.cjs +1 -0
  196. package/dist/TransformOriginView.d.ts +8 -0
  197. package/dist/TransformOriginView.d.ts.map +1 -0
  198. package/dist/TransformOriginView.js +38 -0
  199. package/dist/WheelPicker.cjs +1 -0
  200. package/dist/WheelPicker.d.ts +58 -0
  201. package/dist/WheelPicker.d.ts.map +1 -0
  202. package/dist/WheelPicker.js +167 -0
  203. package/dist/WrapText.cjs +1 -0
  204. package/dist/WrapText.d.ts +83 -0
  205. package/dist/WrapText.d.ts.map +1 -0
  206. package/dist/WrapText.js +93 -0
  207. package/dist/WrapText.test.d.ts +2 -0
  208. package/dist/WrapText.test.d.ts.map +1 -0
  209. package/dist/contrast-slot-map.d.ts +33 -0
  210. package/dist/contrast-slot-map.d.ts.map +1 -0
  211. package/dist/index.cjs +1 -0
  212. package/dist/index.d.ts +64 -0
  213. package/dist/index.d.ts.map +1 -0
  214. package/dist/index.js +54 -0
  215. package/dist/primitives/Image.cjs +1 -0
  216. package/dist/primitives/Image.d.ts +11 -0
  217. package/dist/primitives/Image.d.ts.map +1 -0
  218. package/dist/primitives/Image.js +7 -0
  219. package/dist/primitives/Sprite.cjs +1 -0
  220. package/dist/primitives/Sprite.d.ts +11 -0
  221. package/dist/primitives/Sprite.d.ts.map +1 -0
  222. package/dist/primitives/Sprite.js +7 -0
  223. package/dist/primitives/Text.cjs +1 -0
  224. package/dist/primitives/Text.d.ts +14 -0
  225. package/dist/primitives/Text.d.ts.map +1 -0
  226. package/dist/primitives/Text.js +15 -0
  227. package/dist/primitives/VectorDrawContent.cjs +1 -0
  228. package/dist/primitives/VectorDrawContent.d.ts +3 -0
  229. package/dist/primitives/VectorDrawContent.d.ts.map +1 -0
  230. package/dist/primitives/VectorDrawContent.js +7 -0
  231. package/dist/primitives/View.cjs +1 -0
  232. package/dist/primitives/View.d.ts +13 -0
  233. package/dist/primitives/View.d.ts.map +1 -0
  234. package/dist/primitives/View.js +7 -0
  235. package/dist/primitives/index.d.ts +13 -0
  236. package/dist/primitives/index.d.ts.map +1 -0
  237. package/dist/primitives/primitives.test.d.ts +2 -0
  238. package/dist/primitives/primitives.test.d.ts.map +1 -0
  239. package/dist/primitives.cjs +1 -0
  240. package/dist/primitives.d.ts +2 -0
  241. package/dist/primitives.js +6 -0
  242. package/dist/theme-defaults.cjs +1 -0
  243. package/dist/theme-defaults.d.ts +12 -0
  244. package/dist/theme-defaults.d.ts.map +1 -0
  245. package/dist/theme-defaults.js +1288 -0
  246. package/dist/theme-defaults.test.d.ts +2 -0
  247. package/dist/theme-defaults.test.d.ts.map +1 -0
  248. package/dist/theme-types.cjs +0 -0
  249. package/dist/theme-types.d.ts +708 -0
  250. package/dist/theme-types.d.ts.map +1 -0
  251. package/dist/theme-types.js +0 -0
  252. package/dist/useOverlayPresence.cjs +1 -0
  253. package/dist/useOverlayPresence.d.ts +24 -0
  254. package/dist/useOverlayPresence.d.ts.map +1 -0
  255. package/dist/useOverlayPresence.js +19 -0
  256. package/package.json +83 -0
@@ -0,0 +1,15 @@
1
+ import { View as e } from "./primitives/View.js";
2
+ import "./primitives.js";
3
+ import "@number10/jsx-core";
4
+ import { jsx as t } from "@number10/jsx-core/jsx-runtime";
5
+ //#region src/Divider.tsx
6
+ function n(n) {
7
+ let { orientation: r = "horizontal", thickness: i = 1, color: a = 13421772, length: o } = n, s = r === "horizontal";
8
+ return /* @__PURE__ */ t(e, {
9
+ width: s ? o ?? "100%" : i,
10
+ height: s ? i : o ?? "100%",
11
+ backgroundColor: a
12
+ });
13
+ }
14
+ //#endregion
15
+ export { n as Divider };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Divider.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Divider.test.d.ts","sourceRoot":"","sources":["../src/Divider.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const e=require(`./primitives/Text.cjs`),t=require(`./primitives/View.cjs`);require(`./primitives.cjs`);const n=require(`./Popover.cjs`),r=require(`./TextInput.cjs`),i=require(`./ScrollView.cjs`);require(`./index.cjs`);let a=require(`@number10/jsx-core`),o=require(`@number10/jsx-core/jsx-runtime`);function s(t){let n=t.size??12;return(0,o.jsx)(e.Text,{text:`▼`,style:{color:t.color??`#ffffff`,fontSize:`${n}px`,fontFamily:`Arial, sans-serif`}})}function c(t){let n=t.size??16,r=t.color??`#ffffff`;return t.multiple?(0,o.jsx)(e.Text,{text:t.selected?`☑`:`☐`,style:{color:r,fontSize:`${n}px`,fontFamily:`Arial, sans-serif`}}):t.selected?(0,o.jsx)(e.Text,{text:`✓`,style:{color:r,fontSize:`${n}px`,fontFamily:`Arial, sans-serif`}}):null}function l(l){let u=(0,a.useTheme)(),d=l.theme?(0,a.mergeThemes)(u??{},l.theme):u,{props:f,nestedTheme:p}=(0,a.resolveComponentTheme)({componentName:`Dropdown`,globalTheme:(0,a.getGlobalThemeDefaults)(),localTheme:d,knownComponents:a.KNOWN_COMPONENTS}),[m,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(l.defaultValue??(l.multiple?[]:``)),[v,y]=(0,a.useState)(``),b=(0,a.useRef)(null),x=(0,a.useRef)(null),S=(0,a.useRef)([]),C=l.value!==void 0,w=C?l.value:g,T=f.trigger??{},E=f.overlay??{},D=f.option??{},O=f.textStyle,k=f.placeholderStyle,A=l.maxHeight??E.maxHeight??300,j=f.arrow??{},M=j.size??12,N=j.color??`#ffffff`,P=f.selectionIndicator??{},F=P.size??16,I=P.color??j.color,L=l.placement??`bottom`,R=L===`top`?`top-start`:`bottom-start`,z=(()=>{if(l.multiple){let e=w;return l.options.filter(t=>e.includes(t.value))}let e=l.options.find(e=>e.value===w);return e?[e]:[]})(),[B]=(0,a.useSpring)(m?Math.PI:0,f.animationConfig||`gentle`);(0,a.useForceRedraw)(20,B);let V=()=>{l.disabled||m||(h(!0),y(``),l.onOpen?.(),b.current&&(0,a.applyEffect)(b.current,f.effect??`press`))},H=()=>{m&&(h(!1),y(``),l.onClose?.())},U=e=>{e?V():H()},W=(e,t)=>{if(t?.stopPropagation(),l.multiple){let t=w,n=t.includes(e)?t.filter(t=>t!==e):[...t,e];C||_(n),l.onChange?.(n),(l.closeOnSelect??!1)&&H()}else C||_(e),l.onChange?.(e),(l.closeOnSelect??!0)&&H()},G=()=>l.renderValue?l.renderValue(z.length>0?z:null):z.length===0?(0,o.jsx)(e.Text,{text:l.placeholder??`Select...`,style:k}):l.multiple?(0,o.jsx)(e.Text,{text:`${z.length} selected`,style:O}):(0,o.jsx)(e.Text,{text:z[0]?.label??``,style:O}),K=l.disabled?{...T,...f.triggerDisabled??{}}:m?{...T,...f.triggerOpen??{}}:T,q=l.options.map((n,r)=>{let i=l.multiple?w.includes(n.value):w===n.value,a=n.disabled??!1,s=l.isFilterable?n.label.toLowerCase().includes(v.toLowerCase()):!0,u={...D,...i?f.optionSelected??{}:{},...a?f.optionDisabled??{}:{}};return(0,o.jsx)(t.View,{ref:e=>{S.current[r]=e??null},width:`fill`,direction:`row`,alignItems:`center`,enableGestures:!a,visible:s?!0:`none`,onTouch:e=>{e.stopPropagation(),a||W(n.value,e)},...u,children:l.renderOption?l.renderOption(n,i):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c,{selected:i,multiple:l.multiple===!0,disabled:a,color:I??`#ffffff`,size:F}),n.prefix,(0,o.jsx)(e.Text,{text:n.label}),n.suffix]})},String(n.value))}),J=(0,o.jsxs)(t.View,{ref:b,direction:`row`,alignItems:`center`,justifyContent:`space-between`,...K,children:[(0,o.jsx)(t.View,{flex:1,children:G()}),(0,o.jsx)(t.View,{width:M,height:M,rotation:B.value,children:l.arrow??(0,o.jsx)(s,{color:N,size:M})})]}),Y=f.filterInput??{},X=l.isFilterable&&(0,o.jsx)(t.View,{margin:L===`top`?{top:8}:{bottom:8},children:(0,o.jsx)(r.TextInput,{value:v,onChange:e=>y(e),placeholder:l.filterInputPlaceholder??`Filter...`,height:Y.height,width:Y.width})}),Z=(0,o.jsx)(t.View,{flex:1,width:`fill`,children:(0,o.jsx)(i.ScrollView,{ref:x,showVerticalSlider:`auto`,height:`fill`,width:`100%`,onTouch:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},children:(0,o.jsx)(t.View,{direction:`column`,gap:f.optionGap??2,width:`100%`,theme:O?{Text:{style:O}}:void 0,children:q})})}),Q=(0,a.useRef)(!1);(0,a.useLayoutEffect)(()=>{if(!m){Q.current=!1;return}if(v.length>0||l.multiple&&Q.current)return;let e=l.multiple?l.options.findIndex(e=>w.includes(e.value)):l.options.findIndex(e=>e.value===w);if(e<0)return;let t=S.current[e];t&&(x.current?.scrollChildIntoView(t,{block:`nearest`}),l.multiple&&(Q.current=!0))},[w,v,m,l.multiple,l.options]);let $=(0,o.jsx)(t.View,{direction:`column`,width:`fill`,height:A,overflow:`hidden`,theme:p,...E,children:L===`top`?(0,o.jsxs)(o.Fragment,{children:[Z,X]}):(0,o.jsxs)(o.Fragment,{children:[X,Z]})});return(0,o.jsx)(t.View,{direction:`column`,width:l.width??`fill`,children:(0,o.jsx)(n.Popover,{trigger:J,isOpen:m,onOpenChange:U,placement:R,offset:4,matchTriggerWidth:!0,contentHeight:A,contentProps:{height:A,backgroundAlpha:0,borderWidth:0,padding:0,gap:0,cornerRadius:0},triggerProps:{width:l.width??`fill`},closeOnOutside:!0,closeOnEscape:!0,disabled:l.disabled===!0,theme:{Popover:{backgroundColor:0,backgroundAlpha:0,borderWidth:0,cornerRadius:0,padding:0,gap:0}},children:$})})}exports.Dropdown=l;
@@ -0,0 +1,35 @@
1
+ import { ChildrenType, VNodeLike } from '@number10/jsx-core';
2
+ import { PortableComponentPartialTheme } from './theme-types';
3
+ export interface DropdownOption<T = string> {
4
+ value: T;
5
+ label: string;
6
+ disabled?: boolean;
7
+ prefix?: ChildrenType;
8
+ suffix?: ChildrenType;
9
+ }
10
+ export interface DropdownProps<T = string> {
11
+ key?: string | number | undefined;
12
+ options: DropdownOption<T>[];
13
+ value?: T | T[];
14
+ defaultValue?: T | T[];
15
+ placeholder?: string;
16
+ multiple?: boolean;
17
+ isFilterable?: boolean;
18
+ filterInputPlaceholder?: string;
19
+ disabled?: boolean;
20
+ maxHeight?: number;
21
+ placement?: 'top' | 'bottom';
22
+ renderValue?: (selected: DropdownOption<T> | DropdownOption<T>[] | null) => ChildrenType;
23
+ renderOption?: (option: DropdownOption<T>, isSelected: boolean) => ChildrenType;
24
+ arrow?: ChildrenType;
25
+ onChange?: (value: T | T[]) => void;
26
+ onOpen?: () => void;
27
+ onClose?: () => void;
28
+ closeOnSelect?: boolean;
29
+ width?: unknown;
30
+ height?: unknown;
31
+ ref?: unknown;
32
+ theme?: PortableComponentPartialTheme<'Dropdown'>;
33
+ }
34
+ export declare function Dropdown<T = string>(props: DropdownProps<T>): VNodeLike;
35
+ //# sourceMappingURL=Dropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../src/Dropdown.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;GAOG;AACH,OAAO,KAAK,EACV,YAAY,EAKZ,SAAS,EACV,MAAM,oBAAoB,CAAA;AAsB3B,OAAO,KAAK,EAAiB,6BAA6B,EAAkB,MAAM,eAAe,CAAA;AAMjG,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,MAAM;IACxC,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,MAAM;IACvC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACjC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5B,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;IACf,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAA;IAC5B,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,KAAK,YAAY,CAAA;IACxF,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,KAAK,YAAY,CAAA;IAC/E,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,CAAA;IACnC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,KAAK,CAAC,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAA;CAClD;AAiED,wBAAgB,QAAQ,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAqUvE"}
@@ -0,0 +1,222 @@
1
+ import { Text as e } from "./primitives/Text.js";
2
+ import { View as t } from "./primitives/View.js";
3
+ import "./primitives.js";
4
+ import { Popover as n } from "./Popover.js";
5
+ import { TextInput as r } from "./TextInput.js";
6
+ import { ScrollView as i } from "./ScrollView.js";
7
+ import "./index.js";
8
+ import { KNOWN_COMPONENTS as a, applyEffect as o, getGlobalThemeDefaults as s, mergeThemes as c, resolveComponentTheme as ee, useForceRedraw as l, useLayoutEffect as u, useRef as d, useSpring as f, useState as p, useTheme as te } from "@number10/jsx-core";
9
+ import { Fragment as m, jsx as h, jsxs as g } from "@number10/jsx-core/jsx-runtime";
10
+ //#region src/Dropdown.tsx
11
+ function ne(t) {
12
+ let n = t.size ?? 12;
13
+ return /* @__PURE__ */ h(e, {
14
+ text: "▼",
15
+ style: {
16
+ color: t.color ?? "#ffffff",
17
+ fontSize: `${n}px`,
18
+ fontFamily: "Arial, sans-serif"
19
+ }
20
+ });
21
+ }
22
+ function _(t) {
23
+ let n = t.size ?? 16, r = t.color ?? "#ffffff";
24
+ return t.multiple ? /* @__PURE__ */ h(e, {
25
+ text: t.selected ? "☑" : "☐",
26
+ style: {
27
+ color: r,
28
+ fontSize: `${n}px`,
29
+ fontFamily: "Arial, sans-serif"
30
+ }
31
+ }) : t.selected ? /* @__PURE__ */ h(e, {
32
+ text: "✓",
33
+ style: {
34
+ color: r,
35
+ fontSize: `${n}px`,
36
+ fontFamily: "Arial, sans-serif"
37
+ }
38
+ }) : null;
39
+ }
40
+ function v(v) {
41
+ let y = te(), b = v.theme ? c(y ?? {}, v.theme) : y, { props: x, nestedTheme: S } = ee({
42
+ componentName: "Dropdown",
43
+ globalTheme: s(),
44
+ localTheme: b,
45
+ knownComponents: a
46
+ }), [C, w] = p(!1), [re, T] = p(v.defaultValue ?? (v.multiple ? [] : "")), [E, D] = p(""), O = d(null), k = d(null), A = d([]), j = v.value !== void 0, M = j ? v.value : re, N = x.trigger ?? {}, P = x.overlay ?? {}, ie = x.option ?? {}, F = x.textStyle, ae = x.placeholderStyle, I = v.maxHeight ?? P.maxHeight ?? 300, L = x.arrow ?? {}, R = L.size ?? 12, z = L.color ?? "#ffffff", B = x.selectionIndicator ?? {}, V = B.size ?? 16, H = B.color ?? L.color, U = v.placement ?? "bottom", W = U === "top" ? "top-start" : "bottom-start", G = (() => {
47
+ if (v.multiple) {
48
+ let e = M;
49
+ return v.options.filter((t) => e.includes(t.value));
50
+ }
51
+ let e = v.options.find((e) => e.value === M);
52
+ return e ? [e] : [];
53
+ })(), [K] = f(C ? Math.PI : 0, x.animationConfig || "gentle");
54
+ l(20, K);
55
+ let q = () => {
56
+ v.disabled || C || (w(!0), D(""), v.onOpen?.(), O.current && o(O.current, x.effect ?? "press"));
57
+ }, J = () => {
58
+ C && (w(!1), D(""), v.onClose?.());
59
+ }, oe = (e) => {
60
+ e ? q() : J();
61
+ }, se = (e, t) => {
62
+ if (t?.stopPropagation(), v.multiple) {
63
+ let t = M, n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
64
+ j || T(n), v.onChange?.(n), (v.closeOnSelect ?? !1) && J();
65
+ } else j || T(e), v.onChange?.(e), (v.closeOnSelect ?? !0) && J();
66
+ }, ce = () => v.renderValue ? v.renderValue(G.length > 0 ? G : null) : G.length === 0 ? /* @__PURE__ */ h(e, {
67
+ text: v.placeholder ?? "Select...",
68
+ style: ae
69
+ }) : v.multiple ? /* @__PURE__ */ h(e, {
70
+ text: `${G.length} selected`,
71
+ style: F
72
+ }) : /* @__PURE__ */ h(e, {
73
+ text: G[0]?.label ?? "",
74
+ style: F
75
+ }), le = v.disabled ? {
76
+ ...N,
77
+ ...x.triggerDisabled ?? {}
78
+ } : C ? {
79
+ ...N,
80
+ ...x.triggerOpen ?? {}
81
+ } : N, Y = v.options.map((n, r) => {
82
+ let i = v.multiple ? M.includes(n.value) : M === n.value, a = n.disabled ?? !1, o = v.isFilterable ? n.label.toLowerCase().includes(E.toLowerCase()) : !0, s = {
83
+ ...ie,
84
+ ...i ? x.optionSelected ?? {} : {},
85
+ ...a ? x.optionDisabled ?? {} : {}
86
+ };
87
+ return /* @__PURE__ */ h(t, {
88
+ ref: (e) => {
89
+ A.current[r] = e ?? null;
90
+ },
91
+ width: "fill",
92
+ direction: "row",
93
+ alignItems: "center",
94
+ enableGestures: !a,
95
+ visible: o ? !0 : "none",
96
+ onTouch: (e) => {
97
+ e.stopPropagation(), a || se(n.value, e);
98
+ },
99
+ ...s,
100
+ children: v.renderOption ? v.renderOption(n, i) : /* @__PURE__ */ g(m, { children: [
101
+ /* @__PURE__ */ h(_, {
102
+ selected: i,
103
+ multiple: v.multiple === !0,
104
+ disabled: a,
105
+ color: H ?? "#ffffff",
106
+ size: V
107
+ }),
108
+ n.prefix,
109
+ /* @__PURE__ */ h(e, { text: n.label }),
110
+ n.suffix
111
+ ] })
112
+ }, String(n.value));
113
+ }), ue = /* @__PURE__ */ g(t, {
114
+ ref: O,
115
+ direction: "row",
116
+ alignItems: "center",
117
+ justifyContent: "space-between",
118
+ ...le,
119
+ children: [/* @__PURE__ */ h(t, {
120
+ flex: 1,
121
+ children: ce()
122
+ }), /* @__PURE__ */ h(t, {
123
+ width: R,
124
+ height: R,
125
+ rotation: K.value,
126
+ children: v.arrow ?? /* @__PURE__ */ h(ne, {
127
+ color: z,
128
+ size: R
129
+ })
130
+ })]
131
+ }), X = x.filterInput ?? {}, Z = v.isFilterable && /* @__PURE__ */ h(t, {
132
+ margin: U === "top" ? { top: 8 } : { bottom: 8 },
133
+ children: /* @__PURE__ */ h(r, {
134
+ value: E,
135
+ onChange: (e) => D(e),
136
+ placeholder: v.filterInputPlaceholder ?? "Filter...",
137
+ height: X.height,
138
+ width: X.width
139
+ })
140
+ }), Q = /* @__PURE__ */ h(t, {
141
+ flex: 1,
142
+ width: "fill",
143
+ children: /* @__PURE__ */ h(i, {
144
+ ref: k,
145
+ showVerticalSlider: "auto",
146
+ height: "fill",
147
+ width: "100%",
148
+ onTouch: () => {
149
+ document.activeElement instanceof HTMLElement && document.activeElement.blur();
150
+ },
151
+ children: /* @__PURE__ */ h(t, {
152
+ direction: "column",
153
+ gap: x.optionGap ?? 2,
154
+ width: "100%",
155
+ theme: F ? { Text: { style: F } } : void 0,
156
+ children: Y
157
+ })
158
+ })
159
+ }), $ = d(!1);
160
+ u(() => {
161
+ if (!C) {
162
+ $.current = !1;
163
+ return;
164
+ }
165
+ if (E.length > 0 || v.multiple && $.current) return;
166
+ let e = v.multiple ? v.options.findIndex((e) => M.includes(e.value)) : v.options.findIndex((e) => e.value === M);
167
+ if (e < 0) return;
168
+ let t = A.current[e];
169
+ t && (k.current?.scrollChildIntoView(t, { block: "nearest" }), v.multiple && ($.current = !0));
170
+ }, [
171
+ M,
172
+ E,
173
+ C,
174
+ v.multiple,
175
+ v.options
176
+ ]);
177
+ let de = /* @__PURE__ */ h(t, {
178
+ direction: "column",
179
+ width: "fill",
180
+ height: I,
181
+ overflow: "hidden",
182
+ theme: S,
183
+ ...P,
184
+ children: U === "top" ? /* @__PURE__ */ g(m, { children: [Q, Z] }) : /* @__PURE__ */ g(m, { children: [Z, Q] })
185
+ });
186
+ return /* @__PURE__ */ h(t, {
187
+ direction: "column",
188
+ width: v.width ?? "fill",
189
+ children: /* @__PURE__ */ h(n, {
190
+ trigger: ue,
191
+ isOpen: C,
192
+ onOpenChange: oe,
193
+ placement: W,
194
+ offset: 4,
195
+ matchTriggerWidth: !0,
196
+ contentHeight: I,
197
+ contentProps: {
198
+ height: I,
199
+ backgroundAlpha: 0,
200
+ borderWidth: 0,
201
+ padding: 0,
202
+ gap: 0,
203
+ cornerRadius: 0
204
+ },
205
+ triggerProps: { width: v.width ?? "fill" },
206
+ closeOnOutside: !0,
207
+ closeOnEscape: !0,
208
+ disabled: v.disabled === !0,
209
+ theme: { Popover: {
210
+ backgroundColor: 0,
211
+ backgroundAlpha: 0,
212
+ borderWidth: 0,
213
+ cornerRadius: 0,
214
+ padding: 0,
215
+ gap: 0
216
+ } },
217
+ children: de
218
+ })
219
+ });
220
+ }
221
+ //#endregion
222
+ export { v as Dropdown };
package/dist/Icon.cjs ADDED
@@ -0,0 +1 @@
1
+ const e=require(`./Image.cjs`);let t=require(`@number10/jsx-core`),n=require(`@number10/jsx-core/jsx-runtime`);function r(r){let{type:i,loader:a,size:o=32,...s}=r,[c,l]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!1;if(i==null){l(null);return}return l(e=>e?.type===i?e:null),a(i).then(t=>{e||l({type:i,svg:t})}).catch(t=>{e||console.error(`Failed to load icon ${i}:`,t)}),()=>{e=!0}},[i,a]);let u=(c?.type===i?c:null)?.svg??null,d=i==null?``:`icon-${i}-${o}`;return(0,n.jsx)(e.Image,{texture:u&&(0,t.useSVGTexture)(d,u,o,o)?d:``,width:o,height:o,...s})}function i(e){return function(t){return(0,n.jsx)(r,{...t,loader:e})}}function a(e,n){let[r,i]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!1;return i(t=>t?.type===e?t:null),n(e).then(n=>{t||i({type:e,svg:n})}).catch(n=>{t||console.error(`Failed to load icon ${e}:`,n)}),()=>{t=!0}},[e,n]),r?.type===e}exports.Icon=r,exports.createIconComponent=i,exports.useIconPreload=a;
package/dist/Icon.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ import { VNodeLike } from '@number10/jsx-core';
2
+ import { ImageProps } from './Image';
3
+ /**
4
+ * Icon loader function type.
5
+ * Takes an icon type string and returns a promise resolving to SVG markup.
6
+ */
7
+ export interface IconLoaderFn<T extends string = string> {
8
+ (type: T): Promise<string>;
9
+ }
10
+ /**
11
+ * Props for the generic Icon component.
12
+ */
13
+ export interface IconProps<T extends string = string> extends Omit<ImageProps, 'texture' | 'displayWidth' | 'displayHeight'> {
14
+ /** The icon type/name to load */
15
+ type: T | undefined;
16
+ /** Loader function that fetches the icon SVG */
17
+ loader: IconLoaderFn<T>;
18
+ /** Icon size in pixels (default: 32) */
19
+ size?: number;
20
+ }
21
+ /**
22
+ * Generic Icon component.
23
+ * Loads and displays an icon using the provided loader function.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * <Icon type="check" loader={myIconLoader} size={24} />
28
+ * ```
29
+ */
30
+ export declare function Icon<T extends string = string>(props: IconProps<T>): VNodeLike;
31
+ /**
32
+ * Factory function to create a typed Icon component with a specific loader.
33
+ * This allows creating strongly-typed icon components for specific icon libraries.
34
+ *
35
+ * @param loader - The icon loader function
36
+ * @returns A typed Icon component that doesn't require the loader prop
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // Define your loader
41
+ * async function myIconLoader(type: MyIconType): Promise<string> {
42
+ * const module = await import(`./icons/${type}.svg`)
43
+ * return module.default
44
+ * }
45
+ *
46
+ * // Create typed component
47
+ * export const MyIcon = createIconComponent<MyIconType>(myIconLoader)
48
+ *
49
+ * // Use without loader prop
50
+ * <MyIcon type="check" size={24} />
51
+ * ```
52
+ */
53
+ export declare function createIconComponent<T extends string>(loader: IconLoaderFn<T>): (props: Omit<IconProps<T>, "loader">) => any;
54
+ /**
55
+ * Hook to preload an icon and check if it's ready.
56
+ * Useful for loading icons before they're displayed.
57
+ *
58
+ * @param type - The icon type to load
59
+ * @param loader - The icon loader function
60
+ * @returns true when the icon is loaded and ready to use
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * function MyComponent() {
65
+ * const iconReady = useIconPreload('check', myIconLoader)
66
+ * return iconReady ? <Icon type="check" loader={myIconLoader} /> : <Text text="Loading..." />
67
+ * }
68
+ * ```
69
+ */
70
+ export declare function useIconPreload<T extends string>(type: T, loader: IconLoaderFn<T>): boolean;
71
+ //# sourceMappingURL=Icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../src/Icon.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAMhD;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACrD,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CAChE,UAAU,EACV,SAAS,GAAG,cAAc,GAAG,eAAe,CAC7C;IACC,iCAAiC;IACjC,IAAI,EAAE,CAAC,GAAG,SAAS,CAAA;IACnB,gDAAgD;IAChD,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IACvB,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAMD;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAuC9E;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,SAG9D;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CA0B1F"}
package/dist/Icon.js ADDED
@@ -0,0 +1,57 @@
1
+ import { Image as e } from "./Image.js";
2
+ import { useEffect as t, useSVGTexture as n, useState as r } from "@number10/jsx-core";
3
+ import { jsx as i } from "@number10/jsx-core/jsx-runtime";
4
+ //#region src/Icon.tsx
5
+ function a(a) {
6
+ let { type: o, loader: s, size: c = 32, ...l } = a, [u, d] = r(null);
7
+ t(() => {
8
+ let e = !1;
9
+ if (o == null) {
10
+ d(null);
11
+ return;
12
+ }
13
+ return d((e) => e?.type === o ? e : null), s(o).then((t) => {
14
+ e || d({
15
+ type: o,
16
+ svg: t
17
+ });
18
+ }).catch((t) => {
19
+ e || console.error(`Failed to load icon ${o}:`, t);
20
+ }), () => {
21
+ e = !0;
22
+ };
23
+ }, [o, s]);
24
+ let f = (u?.type === o ? u : null)?.svg ?? null, p = o == null ? "" : `icon-${o}-${c}`;
25
+ return /* @__PURE__ */ i(e, {
26
+ texture: f && n(p, f, c, c) ? p : "",
27
+ width: c,
28
+ height: c,
29
+ ...l
30
+ });
31
+ }
32
+ function o(e) {
33
+ return function(t) {
34
+ return /* @__PURE__ */ i(a, {
35
+ ...t,
36
+ loader: e
37
+ });
38
+ };
39
+ }
40
+ function s(e, n) {
41
+ let [i, a] = r(null);
42
+ return t(() => {
43
+ let t = !1;
44
+ return a((t) => t?.type === e ? t : null), n(e).then((n) => {
45
+ t || a({
46
+ type: e,
47
+ svg: n
48
+ });
49
+ }).catch((n) => {
50
+ t || console.error(`Failed to load icon ${e}:`, n);
51
+ }), () => {
52
+ t = !0;
53
+ };
54
+ }, [e, n]), i?.type === e;
55
+ }
56
+ //#endregion
57
+ export { a as Icon, o as createIconComponent, s as useIconPreload };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Icon.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.test.d.ts","sourceRoot":"","sources":["../src/Icon.test.tsx"],"names":[],"mappings":""}
package/dist/Image.cjs ADDED
@@ -0,0 +1 @@
1
+ let e=require(`@number10/jsx-core`);function t(t){let{theme:n,key:r,...i}=t,a=(0,e.useTheme)(),o=n?(0,e.mergeThemes)(a??{},n):a,{props:s,nestedTheme:c}=(0,e.resolveComponentTheme)({componentName:`Image`,globalTheme:(0,e.getGlobalThemeDefaults)(),localTheme:o,knownComponents:e.KNOWN_COMPONENTS}),l={key:r,theme:c};l.texture=i.texture;for(let[e,t]of Object.entries(i))t!==void 0&&(l[e]=t);return l.displayWidth===void 0&&typeof l.width==`number`&&(l.displayWidth=l.width),l.displayHeight===void 0&&typeof l.height==`number`&&(l.displayHeight=l.height),l.alpha===void 0&&s.alpha!==void 0&&(l.alpha=s.alpha),(0,e.jsx)(e.PRIMITIVE_NODES.Image,l)}exports.Image=t;
@@ -0,0 +1,10 @@
1
+ import { ImagePrimitiveProps, VNodeLike } from '@number10/jsx-core';
2
+ import { PortableComponentPartialTheme } from './theme-types';
3
+ export interface ImageProps extends ImagePrimitiveProps {
4
+ /** Unique key for VDOM identification */
5
+ key?: string | number | undefined;
6
+ /** Optional theme overrides */
7
+ theme?: PortableComponentPartialTheme<'Image'>;
8
+ }
9
+ export declare function Image(props: ImageProps): VNodeLike;
10
+ //# sourceMappingURL=Image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAUxE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAMlE,MAAM,WAAW,UAAW,SAAQ,mBAAmB;IACrD,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACjC,+BAA+B;IAC/B,KAAK,CAAC,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAA;CAC/C;AAMD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CA2ClD"}
package/dist/Image.js ADDED
@@ -0,0 +1,18 @@
1
+ import { KNOWN_COMPONENTS as e, PRIMITIVE_NODES as t, getGlobalThemeDefaults as n, jsx as r, mergeThemes as i, resolveComponentTheme as a, useTheme as o } from "@number10/jsx-core";
2
+ //#region src/Image.tsx
3
+ function s(s) {
4
+ let { theme: c, key: l, ...u } = s, d = o(), f = c ? i(d ?? {}, c) : d, { props: p, nestedTheme: m } = a({
5
+ componentName: "Image",
6
+ globalTheme: n(),
7
+ localTheme: f,
8
+ knownComponents: e
9
+ }), h = {
10
+ key: l,
11
+ theme: m
12
+ };
13
+ h.texture = u.texture;
14
+ for (let [e, t] of Object.entries(u)) t !== void 0 && (h[e] = t);
15
+ return h.displayWidth === void 0 && typeof h.width == "number" && (h.displayWidth = h.width), h.displayHeight === void 0 && typeof h.height == "number" && (h.displayHeight = h.height), h.alpha === void 0 && p.alpha !== void 0 && (h.alpha = p.alpha), r(t.Image, h);
16
+ }
17
+ //#endregion
18
+ export { s as Image };
@@ -0,0 +1 @@
1
+ const e=require(`./primitives/VectorDrawContent.cjs`),t=require(`./primitives/View.cjs`);require(`./primitives.cjs`);let n=require(`@number10/jsx-core`),r=require(`@number10/jsx-core/jsx-runtime`);function i(t,n){function i(t,n=65280){return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(n,.1).fillCircle(0,0,t+10),e.fillStyle(0,.4).fillCircle(0,0,t),e.lineStyle(3,n,1).strokeCircle(0,0,t),e.lineStyle(1,n,.5).strokeCircle(0,0,t-5);for(let r=0;r<4;r++){let i=r*90*Math.PI/180;e.lineStyle(2,n,.7).lineBetween(Math.cos(i)*(t-15),Math.sin(i)*(t-15),Math.cos(i)*(t-5),Math.sin(i)*(t-5))}}})}function a(t,n=65280){let i=t*.4;return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(n,.2).fillCircle(0,0,i+5),e.fillStyle(n,.8).fillCircle(0,0,i),e.lineStyle(2,n,1).strokeCircle(0,0,i),e.lineStyle(2,0,.8),e.moveTo(0,-i*.6).lineTo(0,i*.6),e.moveTo(-i*.6,0).lineTo(i*.6,0),e.strokePath()}})}function o(t,n=16711680){return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(0,.3).fillCircle(0,0,t);for(let r=0;r<3;r++)e.lineStyle(2,n,.6-r*.15).strokeCircle(0,0,t-r*20);e.lineStyle(1,n,.5),e.moveTo(-t,0).lineTo(t,0),e.moveTo(0,-t).lineTo(0,t),e.strokePath(),e.fillStyle(n,.8).fillCircle(0,0,5)}})}function s(t,n=16711680){let i=t*.35;return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(n,.7).fillCircle(0,0,i),e.fillStyle(16777215,.9).fillCircle(0,0,i*.5),e.fillStyle(n,1).fillCircle(0,0,i*.2),e.lineStyle(3,n,1),e.beginPath(),e.moveTo(0,-i).lineTo(i*.3,-i*.6).lineTo(-i*.3,-i*.6),e.closePath().fillPath()}})}function c(t,n=16777215){return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(n,.15).fillCircle(0,0,t),e.fillStyle(n,.3).fillCircle(-t*.3,-t*.3,t*.4),e.lineStyle(2,n,.5).strokeCircle(0,0,t),e.lineStyle(1,n,.3).strokeCircle(0,0,t-3)}})}function l(t,n=16777215){let i=t*.4;return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(0,.2).fillCircle(i*.1,i*.1,i),e.fillStyle(n,.4).fillCircle(0,0,i),e.fillStyle(n,.6).fillCircle(-i*.3,-i*.3,i*.4),e.lineStyle(2,n,.7).strokeCircle(0,0,i)}})}function u(t,n=65280){return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(1710618,.8).fillCircle(0,0,t),e.lineStyle(1,n,.3);for(let n=-t;n<=t;n+=20)e.moveTo(-t,n).lineTo(t,n),e.moveTo(n,-t).lineTo(n,t);e.strokePath(),e.lineStyle(2,n,.6),e.strokeCircle(0,0,t),e.strokeCircle(0,0,t*.66),e.strokeCircle(0,0,t*.33);let r=[-t*.7,t*.7];e.lineStyle(3,n,.8),r.forEach(t=>r.forEach(n=>{e.moveTo(t-10,n).lineTo(t+10,n),e.moveTo(t,n-10).lineTo(t,n+10)})),e.strokePath()}})}function d(t,n=65280){let i=t*.3;return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(n,.9).fillCircle(0,0,i),e.fillStyle(0,1),e.beginPath(),e.moveTo(0,-i).lineTo(i*.5,i*.3).lineTo(-i*.5,i*.3),e.closePath().fillPath(),e.lineStyle(2,0,.8).strokeCircle(0,0,i)}})}function f(t,n=65280){return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.fillStyle(0,.25).lineStyle(1,n),e.fillCircle(0,0,t).strokeCircle(0,0,t)}})}function p(t,n=65280){let i=t*.2;return(0,r.jsx)(e.VectorDrawContent,{onDraw:e=>{e.lineStyle(2,0,1),e.moveTo(0,-i).lineTo(0,i),e.moveTo(-i,0).lineTo(i,0),e.strokePath(),e.lineStyle(2,n,.75).strokeCircle(0,0,i*1.1)}})}let m=t==null?`default`:t.theme,h=(t==null?65280:t.tint)??65280;switch(m){case`neon`:return{base:i(n,h),thumb:a(n,h),rotateThumb:!1};case`target`:return{base:o(n,h),thumb:s(n,h),rotateThumb:!0};case`glass`:return{base:c(n,h),thumb:l(n,h),rotateThumb:!1};case`military`:return{base:u(n,h),thumb:d(n,h),rotateThumb:!0};default:return{base:f(n,h),thumb:p(n,h),rotateThumb:!1}}}function a(e){let[a,o]=(0,n.useState)({x:0,y:0}),[s,c]=(0,n.useState)(0),[l,u]=(0,n.useState)({width:0,height:0}),d=(0,n.useRef)(!1),f=(0,n.useRef)(null),p=(0,n.useRef)(!1),m=(0,n.useRef)(null),h=(0,n.useSurface)()?.scheduler,g=typeof e.width==`number`?e.width:200,_=typeof e.height==`number`?e.height:200,v={x:g/2,y:_/2},y=Math.min(g,_)/2;l.width===0&&Promise.resolve().then(()=>{u({width:g,height:_}),o(v)});let b=e.base!=null&&e.thumb?{base:e.base,thumb:e.thumb,rotateThumb:e.rotateThumb??!1}:i(e.joystickTheme,y),x=e=>{let t=e;return t?t.pointerId??t.id??null:null},S=t=>{t.stopPropagation();let r=x(t.pointer);if(p.current&&r!==m.current)return;if(t.state===`start`&&(d.current=!1,p.current=!0,m.current=r),t.state===`end`){p.current=!1,m.current=null,f.current&&=(f.current.stop(),null),h?f.current=(0,n.createTween)({x:a.x,y:a.y,angle:s},{to:{x:v.x,y:v.y,angle:0},duration:150,onUpdate:e=>{o({x:e.x,y:e.y}),c(e.angle??0)},onComplete:()=>{f.current=null,e.onMove?.(!1,0,0)}},h):(o(v),c(0),e.onMove?.(!1,0,0));return}if(!p.current)return;let i=t.localX-v.x,l=t.localY-v.y,u=Math.sqrt(i*i+l*l),g=y*.6,_=Math.min(u,g),S=Math.atan2(l,i),C=(S*180/Math.PI+360)%360,w=u>0?Math.min(u/g,1):0;o({x:v.x+(u>0?_/u*i:0),y:v.y+(u>0?_/u*l:0)}),(e.rotateThumb??b.rotateThumb)&&c(S);let T=e.minForce??.1;w>T&&(d.current=!0),e.onMove?.(w>T||d.current,C,w)};return(0,r.jsxs)(t.View,{width:e.width,height:e.height,direction:`stack`,enableGestures:!0,onTouchMove:S,onTouchOutside:S,children:[(0,r.jsx)(t.View,{x:v.x,y:v.y,children:b.base}),(0,r.jsx)(t.View,{x:a.x,y:a.y,...b.rotateThumb?{rotation:s}:{},children:b.thumb})]})}exports.Joystick=a;
@@ -0,0 +1,32 @@
1
+ import { SizeValue, VNodeLike } from '@number10/jsx-core';
2
+ export interface JoystickTheme {
3
+ /** Visual theme variant */
4
+ theme: 'default' | 'neon' | 'target' | 'glass' | 'military';
5
+ /** Optional tint color (0xRRGGBB) */
6
+ tint?: number;
7
+ }
8
+ export type JoystickProps = {
9
+ /** Width of the joystick area */
10
+ width: SizeValue;
11
+ /** Height of the joystick area */
12
+ height: SizeValue;
13
+ /** Default theme, used if base and thumb are not provided */
14
+ joystickTheme?: JoystickTheme;
15
+ /** Custom base graphic */
16
+ base?: VNodeLike;
17
+ /** Custom thumb graphic */
18
+ thumb?: VNodeLike;
19
+ /** Minimum force to trigger movement (0.0 to 1.0) */
20
+ minForce?: number;
21
+ /** Enable thumb rotation based on angle */
22
+ rotateThumb?: boolean;
23
+ /** Callback when joystick is moved.
24
+ * @param active - `true` while the joystick is being dragged, `false` on release
25
+ * @param angle - Direction in **degrees** (0–360), 0° = right (→), increases clockwise
26
+ * @param force - Normalized distance from center (0.0–1.0) */
27
+ onMove?: (active: boolean, angle: number, force: number) => void;
28
+ /** Callback when joystick is tapped */
29
+ onTap?: () => void;
30
+ };
31
+ export declare function Joystick(props: JoystickProps): VNodeLike;
32
+ //# sourceMappingURL=Joystick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Joystick.d.ts","sourceRoot":"","sources":["../src/Joystick.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;GAOG;AAEH,OAAO,EAML,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAA;AAK3B,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAA;IAC3D,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAA;IAChB,kCAAkC;IAClC,MAAM,EAAE,SAAS,CAAA;IACjB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,0BAA0B;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;kEAG8D;IAC9D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChE,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AAoOD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAmJxD"}