@stack-spot/citric-react 0.1.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 (345) hide show
  1. package/dist/citric.css +2580 -0
  2. package/dist/components/Accordion.d.ts +33 -0
  3. package/dist/components/Accordion.d.ts.map +1 -0
  4. package/dist/components/Accordion.js +19 -0
  5. package/dist/components/Accordion.js.map +1 -0
  6. package/dist/components/Alert.d.ts +11 -0
  7. package/dist/components/Alert.d.ts.map +1 -0
  8. package/dist/components/Alert.js +5 -0
  9. package/dist/components/Alert.js.map +1 -0
  10. package/dist/components/AsyncContent.d.ts +30 -0
  11. package/dist/components/AsyncContent.d.ts.map +1 -0
  12. package/dist/components/AsyncContent.js +33 -0
  13. package/dist/components/AsyncContent.js.map +1 -0
  14. package/dist/components/Avatar.d.ts +22 -0
  15. package/dist/components/Avatar.d.ts.map +1 -0
  16. package/dist/components/Avatar.js +9 -0
  17. package/dist/components/Avatar.js.map +1 -0
  18. package/dist/components/AvatarGroup.d.ts +25 -0
  19. package/dist/components/AvatarGroup.d.ts.map +1 -0
  20. package/dist/components/AvatarGroup.js +9 -0
  21. package/dist/components/AvatarGroup.js.map +1 -0
  22. package/dist/components/Badge.d.ts +18 -0
  23. package/dist/components/Badge.d.ts.map +1 -0
  24. package/dist/components/Badge.js +7 -0
  25. package/dist/components/Badge.js.map +1 -0
  26. package/dist/components/Blockquote.d.ts +5 -0
  27. package/dist/components/Blockquote.d.ts.map +1 -0
  28. package/dist/components/Blockquote.js +4 -0
  29. package/dist/components/Blockquote.js.map +1 -0
  30. package/dist/components/Breadcrumb.d.ts +12 -0
  31. package/dist/components/Breadcrumb.d.ts.map +1 -0
  32. package/dist/components/Breadcrumb.js +8 -0
  33. package/dist/components/Breadcrumb.js.map +1 -0
  34. package/dist/components/Button.d.ts +42 -0
  35. package/dist/components/Button.d.ts.map +1 -0
  36. package/dist/components/Button.js +25 -0
  37. package/dist/components/Button.js.map +1 -0
  38. package/dist/components/Card.d.ts +19 -0
  39. package/dist/components/Card.d.ts.map +1 -0
  40. package/dist/components/Card.js +5 -0
  41. package/dist/components/Card.js.map +1 -0
  42. package/dist/components/Checkbox.d.ts +14 -0
  43. package/dist/components/Checkbox.d.ts.map +1 -0
  44. package/dist/components/Checkbox.js +7 -0
  45. package/dist/components/Checkbox.js.map +1 -0
  46. package/dist/components/CheckboxGroup.d.ts +53 -0
  47. package/dist/components/CheckboxGroup.d.ts.map +1 -0
  48. package/dist/components/CheckboxGroup.js +17 -0
  49. package/dist/components/CheckboxGroup.js.map +1 -0
  50. package/dist/components/Circle.d.ts +18 -0
  51. package/dist/components/Circle.d.ts.map +1 -0
  52. package/dist/components/Circle.js +5 -0
  53. package/dist/components/Circle.js.map +1 -0
  54. package/dist/components/CitricComponent.d.ts +14 -0
  55. package/dist/components/CitricComponent.d.ts.map +1 -0
  56. package/dist/components/CitricComponent.js +15 -0
  57. package/dist/components/CitricComponent.js.map +1 -0
  58. package/dist/components/Divider.d.ts +14 -0
  59. package/dist/components/Divider.d.ts.map +1 -0
  60. package/dist/components/Divider.js +5 -0
  61. package/dist/components/Divider.js.map +1 -0
  62. package/dist/components/ErrorBoundary.d.ts +32 -0
  63. package/dist/components/ErrorBoundary.d.ts.map +1 -0
  64. package/dist/components/ErrorBoundary.js +46 -0
  65. package/dist/components/ErrorBoundary.js.map +1 -0
  66. package/dist/components/ErrorMessage.d.ts +4 -0
  67. package/dist/components/ErrorMessage.d.ts.map +1 -0
  68. package/dist/components/ErrorMessage.js +7 -0
  69. package/dist/components/ErrorMessage.js.map +1 -0
  70. package/dist/components/FallbackBoundary.d.ts +13 -0
  71. package/dist/components/FallbackBoundary.d.ts.map +1 -0
  72. package/dist/components/FallbackBoundary.js +11 -0
  73. package/dist/components/FallbackBoundary.js.map +1 -0
  74. package/dist/components/Favorite.d.ts +23 -0
  75. package/dist/components/Favorite.d.ts.map +1 -0
  76. package/dist/components/Favorite.js +5 -0
  77. package/dist/components/Favorite.js.map +1 -0
  78. package/dist/components/FieldGroup.d.ts +14 -0
  79. package/dist/components/FieldGroup.d.ts.map +1 -0
  80. package/dist/components/FieldGroup.js +5 -0
  81. package/dist/components/FieldGroup.js.map +1 -0
  82. package/dist/components/Form.d.ts +5 -0
  83. package/dist/components/Form.d.ts.map +1 -0
  84. package/dist/components/Form.js +6 -0
  85. package/dist/components/Form.js.map +1 -0
  86. package/dist/components/FormGroup.d.ts +22 -0
  87. package/dist/components/FormGroup.d.ts.map +1 -0
  88. package/dist/components/FormGroup.js +8 -0
  89. package/dist/components/FormGroup.js.map +1 -0
  90. package/dist/components/IconBox.d.ts +46 -0
  91. package/dist/components/IconBox.d.ts.map +1 -0
  92. package/dist/components/IconBox.js +29 -0
  93. package/dist/components/IconBox.js.map +1 -0
  94. package/dist/components/Input.d.ts +15 -0
  95. package/dist/components/Input.d.ts.map +1 -0
  96. package/dist/components/Input.js +18 -0
  97. package/dist/components/Input.js.map +1 -0
  98. package/dist/components/Link.d.ts +20 -0
  99. package/dist/components/Link.d.ts.map +1 -0
  100. package/dist/components/Link.js +21 -0
  101. package/dist/components/Link.js.map +1 -0
  102. package/dist/components/LoadingPanel.d.ts +2 -0
  103. package/dist/components/LoadingPanel.d.ts.map +1 -0
  104. package/dist/components/LoadingPanel.js +5 -0
  105. package/dist/components/LoadingPanel.js.map +1 -0
  106. package/dist/components/MenuOverlay/Menu.d.ts +6 -0
  107. package/dist/components/MenuOverlay/Menu.d.ts.map +1 -0
  108. package/dist/components/MenuOverlay/Menu.js +100 -0
  109. package/dist/components/MenuOverlay/Menu.js.map +1 -0
  110. package/dist/components/MenuOverlay/context.d.ts +6 -0
  111. package/dist/components/MenuOverlay/context.d.ts.map +1 -0
  112. package/dist/components/MenuOverlay/context.js +16 -0
  113. package/dist/components/MenuOverlay/context.js.map +1 -0
  114. package/dist/components/MenuOverlay/index.d.ts +3 -0
  115. package/dist/components/MenuOverlay/index.d.ts.map +1 -0
  116. package/dist/components/MenuOverlay/index.js +23 -0
  117. package/dist/components/MenuOverlay/index.js.map +1 -0
  118. package/dist/components/MenuOverlay/keyboard.d.ts +2 -0
  119. package/dist/components/MenuOverlay/keyboard.d.ts.map +1 -0
  120. package/dist/components/MenuOverlay/keyboard.js +66 -0
  121. package/dist/components/MenuOverlay/keyboard.js.map +1 -0
  122. package/dist/components/MenuOverlay/types.d.ts +166 -0
  123. package/dist/components/MenuOverlay/types.d.ts.map +1 -0
  124. package/dist/components/MenuOverlay/types.js +2 -0
  125. package/dist/components/MenuOverlay/types.js.map +1 -0
  126. package/dist/components/Overlay/context.d.ts +4 -0
  127. package/dist/components/Overlay/context.d.ts.map +1 -0
  128. package/dist/components/Overlay/context.js +7 -0
  129. package/dist/components/Overlay/context.js.map +1 -0
  130. package/dist/components/Overlay/index.d.ts +14 -0
  131. package/dist/components/Overlay/index.d.ts.map +1 -0
  132. package/dist/components/Overlay/index.js +120 -0
  133. package/dist/components/Overlay/index.js.map +1 -0
  134. package/dist/components/Overlay/types.d.ts +67 -0
  135. package/dist/components/Overlay/types.d.ts.map +1 -0
  136. package/dist/components/Overlay/types.js +2 -0
  137. package/dist/components/Overlay/types.js.map +1 -0
  138. package/dist/components/Pagination.d.ts +28 -0
  139. package/dist/components/Pagination.d.ts.map +1 -0
  140. package/dist/components/Pagination.js +30 -0
  141. package/dist/components/Pagination.js.map +1 -0
  142. package/dist/components/ProgressBar.d.ts +12 -0
  143. package/dist/components/ProgressBar.d.ts.map +1 -0
  144. package/dist/components/ProgressBar.js +7 -0
  145. package/dist/components/ProgressBar.js.map +1 -0
  146. package/dist/components/ProgressCircular.d.ts +16 -0
  147. package/dist/components/ProgressCircular.d.ts.map +1 -0
  148. package/dist/components/ProgressCircular.js +7 -0
  149. package/dist/components/ProgressCircular.js.map +1 -0
  150. package/dist/components/RadioGroup.d.ts +48 -0
  151. package/dist/components/RadioGroup.d.ts.map +1 -0
  152. package/dist/components/RadioGroup.js +17 -0
  153. package/dist/components/RadioGroup.js.map +1 -0
  154. package/dist/components/Rating.d.ts +13 -0
  155. package/dist/components/Rating.d.ts.map +1 -0
  156. package/dist/components/Rating.js +4 -0
  157. package/dist/components/Rating.js.map +1 -0
  158. package/dist/components/Select/RichSelect.d.ts +5 -0
  159. package/dist/components/Select/RichSelect.d.ts.map +1 -0
  160. package/dist/components/Select/RichSelect.js +152 -0
  161. package/dist/components/Select/RichSelect.js.map +1 -0
  162. package/dist/components/Select/SimpleSelect.d.ts +5 -0
  163. package/dist/components/Select/SimpleSelect.d.ts.map +1 -0
  164. package/dist/components/Select/SimpleSelect.js +24 -0
  165. package/dist/components/Select/SimpleSelect.js.map +1 -0
  166. package/dist/components/Select/index.d.ts +4 -0
  167. package/dist/components/Select/index.d.ts.map +1 -0
  168. package/dist/components/Select/index.js +7 -0
  169. package/dist/components/Select/index.js.map +1 -0
  170. package/dist/components/Select/types.d.ts +118 -0
  171. package/dist/components/Select/types.d.ts.map +1 -0
  172. package/dist/components/Select/types.js +2 -0
  173. package/dist/components/Select/types.js.map +1 -0
  174. package/dist/components/SelectBox.d.ts +65 -0
  175. package/dist/components/SelectBox.d.ts.map +1 -0
  176. package/dist/components/SelectBox.js +26 -0
  177. package/dist/components/SelectBox.js.map +1 -0
  178. package/dist/components/Skeleton.d.ts +30 -0
  179. package/dist/components/Skeleton.d.ts.map +1 -0
  180. package/dist/components/Skeleton.js +5 -0
  181. package/dist/components/Skeleton.js.map +1 -0
  182. package/dist/components/Slider.d.ts +32 -0
  183. package/dist/components/Slider.d.ts.map +1 -0
  184. package/dist/components/Slider.js +19 -0
  185. package/dist/components/Slider.js.map +1 -0
  186. package/dist/components/SmartTable.d.ts +87 -0
  187. package/dist/components/SmartTable.d.ts.map +1 -0
  188. package/dist/components/SmartTable.js +16 -0
  189. package/dist/components/SmartTable.js.map +1 -0
  190. package/dist/components/Stepper.d.ts +52 -0
  191. package/dist/components/Stepper.d.ts.map +1 -0
  192. package/dist/components/Stepper.js +53 -0
  193. package/dist/components/Stepper.js.map +1 -0
  194. package/dist/components/Switch.d.ts +10 -0
  195. package/dist/components/Switch.d.ts.map +1 -0
  196. package/dist/components/Switch.js +7 -0
  197. package/dist/components/Switch.js.map +1 -0
  198. package/dist/components/Table.d.ts +106 -0
  199. package/dist/components/Table.d.ts.map +1 -0
  200. package/dist/components/Table.js +86 -0
  201. package/dist/components/Table.js.map +1 -0
  202. package/dist/components/Tabs/TabController.d.ts +11 -0
  203. package/dist/components/Tabs/TabController.d.ts.map +1 -0
  204. package/dist/components/Tabs/TabController.js +39 -0
  205. package/dist/components/Tabs/TabController.js.map +1 -0
  206. package/dist/components/Tabs/index.d.ts +5 -0
  207. package/dist/components/Tabs/index.d.ts.map +1 -0
  208. package/dist/components/Tabs/index.js +37 -0
  209. package/dist/components/Tabs/index.js.map +1 -0
  210. package/dist/components/Tabs/types.d.ts +46 -0
  211. package/dist/components/Tabs/types.d.ts.map +1 -0
  212. package/dist/components/Tabs/types.js +2 -0
  213. package/dist/components/Tabs/types.js.map +1 -0
  214. package/dist/components/Tabs/utils.d.ts +3 -0
  215. package/dist/components/Tabs/utils.d.ts.map +1 -0
  216. package/dist/components/Tabs/utils.js +5 -0
  217. package/dist/components/Tabs/utils.js.map +1 -0
  218. package/dist/components/Text.d.ts +27 -0
  219. package/dist/components/Text.d.ts.map +1 -0
  220. package/dist/components/Text.js +45 -0
  221. package/dist/components/Text.js.map +1 -0
  222. package/dist/components/Textarea.d.ts +8 -0
  223. package/dist/components/Textarea.d.ts.map +1 -0
  224. package/dist/components/Textarea.js +4 -0
  225. package/dist/components/Textarea.js.map +1 -0
  226. package/dist/components/Tooltip.d.ts +25 -0
  227. package/dist/components/Tooltip.d.ts.map +1 -0
  228. package/dist/components/Tooltip.js +18 -0
  229. package/dist/components/Tooltip.js.map +1 -0
  230. package/dist/components/layout.d.ts +46 -0
  231. package/dist/components/layout.d.ts.map +1 -0
  232. package/dist/components/layout.js +18 -0
  233. package/dist/components/layout.js.map +1 -0
  234. package/dist/context/CitricContext.d.ts +3 -0
  235. package/dist/context/CitricContext.d.ts.map +1 -0
  236. package/dist/context/CitricContext.js +3 -0
  237. package/dist/context/CitricContext.js.map +1 -0
  238. package/dist/context/CitricProvider.d.ts +9 -0
  239. package/dist/context/CitricProvider.d.ts.map +1 -0
  240. package/dist/context/CitricProvider.js +8 -0
  241. package/dist/context/CitricProvider.js.map +1 -0
  242. package/dist/context/hooks.d.ts +2 -0
  243. package/dist/context/hooks.d.ts.map +1 -0
  244. package/dist/context/hooks.js +6 -0
  245. package/dist/context/hooks.js.map +1 -0
  246. package/dist/index.d.ts +48 -0
  247. package/dist/index.d.ts.map +1 -0
  248. package/dist/index.js +48 -0
  249. package/dist/index.js.map +1 -0
  250. package/dist/overlay.d.ts +83 -0
  251. package/dist/overlay.d.ts.map +1 -0
  252. package/dist/overlay.js +199 -0
  253. package/dist/overlay.js.map +1 -0
  254. package/dist/theme.css +419 -0
  255. package/dist/types.d.ts +175 -0
  256. package/dist/types.d.ts.map +1 -0
  257. package/dist/types.js +2 -0
  258. package/dist/types.js.map +1 -0
  259. package/dist/utils/ValueController.d.ts +10 -0
  260. package/dist/utils/ValueController.d.ts.map +1 -0
  261. package/dist/utils/ValueController.js +32 -0
  262. package/dist/utils/ValueController.js.map +1 -0
  263. package/dist/utils/acessibility.d.ts +52 -0
  264. package/dist/utils/acessibility.d.ts.map +1 -0
  265. package/dist/utils/acessibility.js +80 -0
  266. package/dist/utils/acessibility.js.map +1 -0
  267. package/dist/utils/css.d.ts +12 -0
  268. package/dist/utils/css.d.ts.map +1 -0
  269. package/dist/utils/css.js +72 -0
  270. package/dist/utils/css.js.map +1 -0
  271. package/dist/utils/options.d.ts +3 -0
  272. package/dist/utils/options.d.ts.map +1 -0
  273. package/dist/utils/options.js +7 -0
  274. package/dist/utils/options.js.map +1 -0
  275. package/package.json +51 -0
  276. package/scripts/build-css.ts +49 -0
  277. package/src/components/Accordion.tsx +74 -0
  278. package/src/components/Alert.tsx +16 -0
  279. package/src/components/AsyncContent.tsx +54 -0
  280. package/src/components/Avatar.tsx +34 -0
  281. package/src/components/AvatarGroup.tsx +40 -0
  282. package/src/components/Badge.tsx +28 -0
  283. package/src/components/Blockquote.tsx +9 -0
  284. package/src/components/Breadcrumb.tsx +24 -0
  285. package/src/components/Button.tsx +88 -0
  286. package/src/components/Card.tsx +32 -0
  287. package/src/components/Checkbox.tsx +36 -0
  288. package/src/components/CheckboxGroup.tsx +93 -0
  289. package/src/components/Circle.tsx +26 -0
  290. package/src/components/CitricComponent.ts +34 -0
  291. package/src/components/Divider.tsx +22 -0
  292. package/src/components/ErrorBoundary.tsx +62 -0
  293. package/src/components/ErrorMessage.tsx +11 -0
  294. package/src/components/FallbackBoundary.tsx +29 -0
  295. package/src/components/Favorite.tsx +37 -0
  296. package/src/components/FieldGroup.tsx +22 -0
  297. package/src/components/Form.tsx +17 -0
  298. package/src/components/FormGroup.tsx +45 -0
  299. package/src/components/IconBox.tsx +78 -0
  300. package/src/components/Input.tsx +32 -0
  301. package/src/components/Link.tsx +40 -0
  302. package/src/components/LoadingPanel.tsx +8 -0
  303. package/src/components/MenuOverlay/Menu.tsx +157 -0
  304. package/src/components/MenuOverlay/context.ts +20 -0
  305. package/src/components/MenuOverlay/index.tsx +35 -0
  306. package/src/components/MenuOverlay/keyboard.ts +60 -0
  307. package/src/components/MenuOverlay/types.ts +178 -0
  308. package/src/components/Overlay/context.ts +10 -0
  309. package/src/components/Overlay/index.tsx +137 -0
  310. package/src/components/Overlay/types.ts +71 -0
  311. package/src/components/Pagination.tsx +90 -0
  312. package/src/components/ProgressBar.tsx +25 -0
  313. package/src/components/ProgressCircular.tsx +29 -0
  314. package/src/components/RadioGroup.tsx +87 -0
  315. package/src/components/Rating.tsx +25 -0
  316. package/src/components/Select/RichSelect.tsx +214 -0
  317. package/src/components/Select/SimpleSelect.tsx +66 -0
  318. package/src/components/Select/index.tsx +8 -0
  319. package/src/components/Select/types.ts +121 -0
  320. package/src/components/SelectBox.tsx +134 -0
  321. package/src/components/Skeleton.tsx +41 -0
  322. package/src/components/Slider.tsx +77 -0
  323. package/src/components/SmartTable.tsx +148 -0
  324. package/src/components/Stepper.tsx +142 -0
  325. package/src/components/Switch.tsx +29 -0
  326. package/src/components/Table.tsx +219 -0
  327. package/src/components/Tabs/TabController.ts +40 -0
  328. package/src/components/Tabs/index.tsx +64 -0
  329. package/src/components/Tabs/types.ts +48 -0
  330. package/src/components/Tabs/utils.ts +6 -0
  331. package/src/components/Text.ts +75 -0
  332. package/src/components/Textarea.tsx +12 -0
  333. package/src/components/Tooltip.tsx +53 -0
  334. package/src/components/layout.tsx +53 -0
  335. package/src/context/CitricContext.tsx +4 -0
  336. package/src/context/CitricProvider.tsx +14 -0
  337. package/src/context/hooks.ts +6 -0
  338. package/src/index.ts +47 -0
  339. package/src/overlay.ts +276 -0
  340. package/src/types.ts +226 -0
  341. package/src/utils/ValueController.ts +28 -0
  342. package/src/utils/acessibility.ts +92 -0
  343. package/src/utils/css.ts +106 -0
  344. package/src/utils/options.ts +7 -0
  345. package/tsconfig.json +10 -0
@@ -0,0 +1,118 @@
1
+ import { HTMLExtension, WithColorScheme } from '../../types.js';
2
+ interface CommonSelectProps<T> extends WithColorScheme {
3
+ /**
4
+ * All the items (options) to render.
5
+ */
6
+ options: T[];
7
+ /**
8
+ * If the value is undefined or "", an empty option is rendered. This option will disappear as soon as a valid option is selected, unless
9
+ * "required" is set to false.
10
+ */
11
+ value?: T;
12
+ /**
13
+ * Called whenever the selected option changes.
14
+ * @param value the currently selected item.
15
+ */
16
+ onChange?: (value: T | undefined) => void;
17
+ /**
18
+ * A function to render the item label.
19
+ * @example
20
+ * `(option) => option.name`
21
+ * @default "the item's toString() result."
22
+ * @param option the item to render.
23
+ * @returns a React Node to render.
24
+ */
25
+ renderLabel?: (value: T) => string;
26
+ /**
27
+ * A function to render the item value, a unique identifier for the option.
28
+ * @example
29
+ * `(option) => option.id`
30
+ * @default "if the item is a string or a number, the stringified item. Otherwise, undefined."
31
+ * @param option the item to compute a key for.
32
+ * @returns a string key.
33
+ */
34
+ renderKey?: (value: T) => string | number | undefined;
35
+ /**
36
+ * Whether or not this input is required. This is also used to figure out if an empty option should be rendered or not.
37
+ *
38
+ * An empty option is rendered whenever "required" is false or "value" is "" or undefined.
39
+ * @default true
40
+ */
41
+ required?: boolean;
42
+ /**
43
+ * Whether or not to show a loading feedback to the user.
44
+ *
45
+ * Attention: selects that are loading should normally also be disabled.
46
+ */
47
+ loading?: boolean;
48
+ /**
49
+ * Whether or not this field is disabled.
50
+ * @default false
51
+ */
52
+ disabled?: boolean;
53
+ /**
54
+ * Function to run when the element receives focus. If the native select element received focus, a Select element is the target, otherwise
55
+ * the wrapping div element is.
56
+ *
57
+ * If `rich` is false, the target will always be a select element.
58
+ */
59
+ onFocus?: React.EventHandler<React.FocusEvent<HTMLDivElement | HTMLSelectElement>>;
60
+ /**
61
+ * Function to run when the element loses focus. If the native select element received focus, a Select element is the target, otherwise
62
+ * the wrapping div element is.
63
+ *
64
+ * If `rich` is false, the target will always be a select element.
65
+ */
66
+ onBlur?: React.EventHandler<React.FocusEvent<HTMLDivElement | HTMLSelectElement>>;
67
+ /**
68
+ * If the type is "simple", the native select element is rendered.
69
+ *
70
+ * If the type is "rich", a custom select is rendered and more options are enabled, like "searchable".
71
+ *
72
+ * @default 'rich'
73
+ */
74
+ type?: 'simple' | 'rich';
75
+ }
76
+ export interface SimpleSelectProps<T> extends CommonSelectProps<T> {
77
+ type: 'simple';
78
+ }
79
+ export interface RichSelectProps<T> extends CommonSelectProps<T> {
80
+ type?: 'rich';
81
+ /**
82
+ * Whether or not to render a search field. The search is based on the value returned by `renderLabel`.
83
+ *
84
+ * @default false
85
+ */
86
+ searchable?: boolean;
87
+ /**
88
+ * A function to render the option in the selectable list.
89
+ *
90
+ * The `renderLabel` function is used if this is not provided.
91
+ * @param value the option.
92
+ * @returns the React Node.
93
+ */
94
+ renderOption?: (value: T) => React.ReactNode;
95
+ /**
96
+ * A function to render the selected option in the header.
97
+ *
98
+ * The `renderOption` function is used if this is not provided.
99
+ * @param value the option.
100
+ * @returns the React Node.
101
+ */
102
+ renderHeader?: (value: T | undefined) => React.ReactNode;
103
+ /**
104
+ * The maximum height of the options list in pixels.
105
+ *
106
+ * @default 300
107
+ */
108
+ maxHeight?: number;
109
+ /**
110
+ * Whether or not to show the arrow inside the select's header.
111
+ * @default true
112
+ */
113
+ showArrow?: boolean;
114
+ }
115
+ export type BaseSelectProps<T> = SimpleSelectProps<T> | RichSelectProps<T>;
116
+ export type SelectProps<T> = HTMLExtension<'div', BaseSelectProps<T>, 'onChange' | 'children'>;
117
+ export {};
118
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE5D,UAAU,iBAAiB,CAAC,CAAC,CAAE,SAAQ,eAAe;IACpD;;OAEG;IACH,OAAO,EAAE,CAAC,EAAE,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,CAAC;IACV;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;IAC1C;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACnC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,GAAG,iBAAiB,CAAC,CAAC,CAAC;IACnF;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,GAAG,iBAAiB,CAAC,CAAC,CAAC;IAClF;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAChE,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC7C;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;IACzD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Select/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,65 @@
1
+ import { HTMLExtension, WithColorPalette, WithColorScheme } from '../types.js';
2
+ export interface SelectBoxLabel {
3
+ icon?: React.ReactElement;
4
+ title: string;
5
+ description?: string;
6
+ }
7
+ export interface CommonSelectBoxProps<T> extends WithColorPalette, WithColorScheme {
8
+ /**
9
+ * If multiple is true, checkboxes will be rendered instead of radio buttons.
10
+ *
11
+ * @default false
12
+ */
13
+ multiple?: boolean;
14
+ /**
15
+ * The name for all checkboxes or radio buttons.
16
+ */
17
+ name?: string;
18
+ /**
19
+ * The options to show as select boxes.
20
+ */
21
+ options: T[];
22
+ /**
23
+ * A function that returns the data to render a select box for an option.
24
+ *
25
+ * @default "extracts the title by converting the option to a string"
26
+ */
27
+ renderLabel?: (option: T) => SelectBoxLabel;
28
+ /**
29
+ * A function that returns a unique identifier for an option.
30
+ *
31
+ * @default "if the option is a string, uses it as the key. Otherwise, the key won't be specified."
32
+ */
33
+ renderKey?: (option: T) => string | number | undefined;
34
+ /**
35
+ * A function that receives an option and decides if it's disabled or not.
36
+ */
37
+ isDisabled?: (option: T) => boolean;
38
+ /**
39
+ * Whether to render a row (horizontal) or a column (vertical).
40
+ *
41
+ * @default 'horizontal'
42
+ */
43
+ direction?: 'horizontal' | 'vertical';
44
+ /**
45
+ * The background color level.
46
+ *
47
+ * @default 300
48
+ */
49
+ bgLevel?: 300 | 400 | 500 | 600 | 700;
50
+ }
51
+ interface CheckboxProps<T> extends CommonSelectBoxProps<T> {
52
+ multiple: true;
53
+ value?: T[];
54
+ onChange?: (value: T[]) => void;
55
+ }
56
+ interface RadioProps<T> extends CommonSelectBoxProps<T> {
57
+ multiple?: false;
58
+ value?: T;
59
+ onChange?: (value: T) => void;
60
+ }
61
+ export type BaseSelectBoxProps<T> = RadioProps<T> | CheckboxProps<T>;
62
+ export type SelectBoxProps<T> = HTMLExtension<'div', BaseSelectBoxProps<T>, 'onChange'>;
63
+ export declare function SelectBox<T>({ multiple, name, value, options, onChange, renderLabel, renderKey, isDisabled, className, style, direction, bgLevel, colorPalette, colorScheme, ...props }: SelectBoxProps<T>): import("react/jsx-runtime").JSX.Element;
64
+ export {};
65
+ //# sourceMappingURL=SelectBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectBox.d.ts","sourceRoot":"","sources":["../../src/components/SelectBox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAK3E,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,gBAAgB,EAAE,eAAe;IAChF;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,CAAC,EAAE,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,cAAc,CAAC;IAC5C;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC;;;;OAIG;IACH,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CACvC;AAED,UAAU,aAAa,CAAC,CAAC,CAAE,SAAQ,oBAAoB,CAAC,CAAC,CAAC;IACxD,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CACjC;AAED,UAAU,UAAU,CAAC,CAAC,CAAE,SAAQ,oBAAoB,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;AAEpE,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;AAEvF,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAC3B,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,WAAqD,EACrD,SAA4B,EAC5B,UAAU,EACV,SAAS,EACT,KAAK,EACL,SAAS,EACT,OAAO,EACP,YAAY,EACZ,WAAW,EACX,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,CAAC,CAAC,2CA2CnB"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { listToClass } from '@stack-spot/portal-theme';
3
+ import { useMemo } from 'react';
4
+ import { defaultRenderKey, defaultRenderLabel } from '../utils/options.js';
5
+ import { CitricComponent } from './CitricComponent.js';
6
+ import { layout } from './layout.js';
7
+ export function SelectBox({ multiple, name, value, options, onChange, renderLabel = o => ({ title: defaultRenderLabel(o) }), renderKey = defaultRenderKey, isDisabled, className, style, direction, bgLevel, colorPalette, colorScheme, ...props }) {
8
+ const items = useMemo(() => {
9
+ const valueAsArray = value ? (Array.isArray(value) ? value : [value]) : [];
10
+ const valueKeys = valueAsArray.map(renderKey);
11
+ return options.map((o) => {
12
+ const key = renderKey(o);
13
+ const label = renderLabel(o);
14
+ return (_jsxs(CitricComponent, { tag: "label", component: "select-box", className: bgLevel ? `bg-${bgLevel}` : undefined, children: [_jsx("input", { type: multiple ? 'checkbox' : 'radio', name: name, value: key, checked: value ? valueKeys.includes(key) : undefined, disabled: isDisabled?.(o), onChange: onChange ? (e) => {
15
+ if (multiple) {
16
+ onChange(e.target.checked ? [...valueAsArray, o] : valueAsArray.filter(v => renderKey(v) !== key));
17
+ }
18
+ else {
19
+ onChange(o);
20
+ }
21
+ } : undefined }), _jsxs("div", { className: "option", children: [label.icon, _jsx("p", { className: "title", children: label.title }), label.description && _jsx("p", { className: "description", children: label.description })] })] }, key));
22
+ });
23
+ }, [options, value, name, multiple, bgLevel]);
24
+ return (_jsx("div", { "data-color-palette": colorPalette, "data-color-scheme": colorScheme, className: listToClass([className, direction === 'vertical' ? layout.column : layout.row]), style: { gap: '5px', ...style }, ...props, children: items }));
25
+ }
26
+ //# sourceMappingURL=SelectBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectBox.js","sourceRoot":"","sources":["../../src/components/SelectBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAqEjC,MAAM,UAAU,SAAS,CAAI,EAC3B,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,EACrD,SAAS,GAAG,gBAAgB,EAC5B,UAAU,EACV,SAAS,EACT,KAAK,EACL,SAAS,EACT,OAAO,EACP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AAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;4BACpG,CAAC;iCAAM,CAAC;gCACN,QAAQ,CAAC,CAAC,CAAC,CAAA;4BACb,CAAC;wBACH,CAAC,CAAC,CAAC,CAAC,SAAS,GACb,EACF,eAAK,SAAS,EAAC,QAAQ,aACpB,KAAK,CAAC,IAAI,EACX,YAAG,SAAS,EAAC,OAAO,YAAE,KAAK,CAAC,KAAK,GAAK,EACrC,KAAK,CAAC,WAAW,IAAI,YAAG,SAAS,EAAC,aAAa,YAAE,KAAK,CAAC,WAAW,GAAK,IACpE,KAnBc,GAAG,CAoBP,CACnB,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;IAC7C,OAAO,CACL,oCACsB,YAAY,uBACb,WAAW,EAC9B,SAAS,EAAE,WAAW,CAAC,CAAC,SAAS,EAAE,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAC1F,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,KAC3B,KAAK,YAER,KAAK,GACF,CACP,CAAA;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { HTMLExtension } from '../types.js';
2
+ export interface BaseSkeletonProps {
3
+ /**
4
+ * The skeleton's appearance.
5
+ *
6
+ * @default 'square'
7
+ */
8
+ appearance?: 'square' | 'circle';
9
+ /**
10
+ * The skeleton's width.
11
+ *
12
+ * @default "the available width if 'square', 50px if 'circle'".
13
+ */
14
+ width?: string;
15
+ /**
16
+ * The skeleton's width.
17
+ *
18
+ * @default "32px if 'square', 50px if 'circle'".
19
+ */
20
+ height?: string;
21
+ /**
22
+ * The background color level.
23
+ *
24
+ * @default 500
25
+ */
26
+ bgLevel?: 400 | 500 | 600;
27
+ }
28
+ export type SkeletonProps = HTMLExtension<'div', BaseSkeletonProps, 'children'>;
29
+ export declare const Skeleton: ({ appearance, className, style, width, height, bgLevel, ...props }: SkeletonProps) => import("react/jsx-runtime").JSX.Element;
30
+ //# sourceMappingURL=Skeleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.d.ts","sourceRoot":"","sources":["../../src/components/Skeleton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAA;AAE/E,eAAO,MAAM,QAAQ,GAAI,oEAAoE,aAAa,4CAOtG,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { listToClass } from '@stack-spot/portal-theme';
3
+ import { CitricComponent } from './CitricComponent.js';
4
+ export const Skeleton = ({ appearance, className, style, width, height, bgLevel, ...props }) => _jsx(CitricComponent, { tag: "div", component: "skeleton", className: listToClass([appearance, bgLevel && `bg-${bgLevel}`, className]), style: { width, height, ...style }, ...props });
5
+ //# sourceMappingURL=Skeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.js","sourceRoot":"","sources":["../../src/components/Skeleton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AA+BnD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAiB,EAAE,EAAE,CAC5G,KAAC,eAAe,IACd,GAAG,EAAC,KAAK,EACT,SAAS,EAAC,UAAU,EACpB,SAAS,EAAE,WAAW,CAAC,CAAC,UAAU,EAAE,OAAO,IAAI,MAAM,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC,EAC3E,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,KAC9B,KAAK,GACT,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { HTMLExtension, WithColorPalette, WithColorScheme } from '../types.js';
2
+ export interface BaseSliderProps extends WithColorScheme, WithColorPalette {
3
+ value: number;
4
+ /**
5
+ * The minimum value in the numeric range.
6
+ *
7
+ * @default 0
8
+ */
9
+ min?: number;
10
+ /**
11
+ * The maximum value in the numeric range.
12
+ *
13
+ * @default 100
14
+ */
15
+ max?: number;
16
+ onChange: (value: number) => void;
17
+ /**
18
+ * When should we render the current value of the input?
19
+ *
20
+ * @default 'always'
21
+ */
22
+ showValue?: 'always' | 'hover' | 'never';
23
+ /**
24
+ * A function to customize how the value of the input is rendered.
25
+ *
26
+ * @default "{value}% if 'min' and 'max' are not provided. {value} otherwise."
27
+ */
28
+ renderValue?: (value: number) => string;
29
+ }
30
+ export type SliderProps = HTMLExtension<'input', BaseSliderProps, 'children' | 'type' | 'value' | 'onChange'>;
31
+ export declare const Slider: ({ value, onChange, min, max, style, showValue, renderValue, colorPalette, colorScheme, className, ...props }: SliderProps) => import("react/jsx-runtime").JSX.Element;
32
+ //# sourceMappingURL=Slider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../src/components/Slider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAI3E,MAAM,WAAW,eAAgB,SAAQ,eAAe,EAAE,gBAAgB;IACxE,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IACzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACzC;AAED,MAAM,MAAM,WAAW,GAAI,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,CAAA;AAE9G,eAAO,MAAM,MAAM,GACjB,8GAA8G,WAAW,4CAsC1H,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { listToClass } from '@stack-spot/portal-theme';
3
+ import { applyCSSVariable } from '../utils/css.js';
4
+ import { CitricComponent } from './CitricComponent.js';
5
+ export const Slider = ({ value, onChange, min, max, style, showValue, renderValue, colorPalette, colorScheme, className, ...props }) => {
6
+ const percent = Math.floor((value / ((max ?? 100) - (min ?? 0))) * 100);
7
+ style = applyCSSVariable(style, 'percent', percent);
8
+ const rangeProps = {
9
+ value,
10
+ min,
11
+ max,
12
+ onChange: (e) => onChange(parseInt(e.target.value)),
13
+ ...props,
14
+ };
15
+ return showValue === 'never'
16
+ ? _jsx(CitricComponent, { tag: "input", type: "range", component: "slider", style: style, className: className, colorPalette: colorPalette, colorScheme: colorScheme, ...rangeProps })
17
+ : (_jsxs(CitricComponent, { tag: "div", component: "labeled-slider", style: style, colorPalette: colorPalette, colorScheme: colorScheme, className: listToClass([className, showValue === 'hover' && 'value-on-hover']), children: [_jsx("input", { type: "range", ...rangeProps }), _jsx("div", { className: "value", children: renderValue ? renderValue(value) : `${value}${min === undefined && max === undefined ? '%' : ''}` })] }));
18
+ };
19
+ //# sourceMappingURL=Slider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../src/components/Slider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAiCnD,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAe,EACzH,EAAE;IACF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IACvE,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IACnD,MAAM,UAAU,GAAG;QACjB,KAAK;QACL,GAAG;QACH,GAAG;QACH,QAAQ,EAAE,CAAC,CAAsC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxF,GAAG,KAAK;KACT,CAAA;IAED,OAAO,SAAS,KAAK,OAAO;QAC1B,CAAC,CAAC,KAAC,eAAe,IAChB,GAAG,EAAC,OAAO,EACX,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,KACpB,UAAU,GACd;QACF,CAAC,CAAC,CACA,MAAC,eAAe,IACd,GAAG,EAAC,KAAK,EACT,SAAS,EAAC,gBAAgB,EAC1B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,WAAW,CAAC,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,IAAI,gBAAgB,CAAC,CAAC,aAE9E,gBAAO,IAAI,EAAC,OAAO,KAAK,UAAU,GAAI,EACtC,cAAK,SAAS,EAAC,OAAO,YACnB,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,GAC9F,IACU,CACnB,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,87 @@
1
+ import { BaseTableProps, SortingDirection, TableProps } from './Table.js';
2
+ export type TableColumn<T> = {
3
+ /**
4
+ * A unique identifier for the column.
5
+ */
6
+ key: string;
7
+ /**
8
+ * A label to use as the column's header.
9
+ *
10
+ * If not provided, the key will be used.
11
+ */
12
+ label?: React.ReactNode;
13
+ /**
14
+ * A custom render function. It receives the item (row) and must return a React node.
15
+ *
16
+ * If not provided, the value of `item[key]` will be converted to a string and used. If it's undefined, an empty string is rendered.
17
+ *
18
+ * @param item the current item.
19
+ * @returns the React Node to render.
20
+ */
21
+ render?: (item: T) => React.ReactNode;
22
+ /**
23
+ * What to do when the header is clicked (sorting)
24
+ */
25
+ onSort?: (value: SortingDirection | undefined) => void;
26
+ /**
27
+ * Which is the current direction of the sorting? Only relevant if 'onSort' is set.
28
+ *
29
+ * @default 'desc'
30
+ */
31
+ direction?: SortingDirection;
32
+ /**
33
+ * Additional properties for the "th" corresponding to this column.
34
+ */
35
+ th?: Omit<JSX.IntrinsicElements['th'], 'children'>;
36
+ /**
37
+ * Additional properties for the "td" corresponding to this column.
38
+ */
39
+ td?: Omit<JSX.IntrinsicElements['td'], 'children'>;
40
+ };
41
+ interface ExtraSmartTableProps<T extends Record<string, any>> {
42
+ /**
43
+ * An array where each item is a row in the table.
44
+ */
45
+ data: T[];
46
+ /**
47
+ * A function to generate a unique key for each item. If not provided, the item's index will be used.
48
+ * @param item
49
+ * @returns a unique key
50
+ */
51
+ keygen?: (item: T) => React.Key;
52
+ /**
53
+ * The columns to display in the table.
54
+ *
55
+ * Attention: always save your columns with `useMemo` to avoid unnecessary rerenders.
56
+ */
57
+ columns: TableColumn<T>[];
58
+ /**
59
+ * If set, an extra row and column for each item is rendered. The extra row is collapsed by default and can be expanded through a button
60
+ * that is placed in the extra column.
61
+ *
62
+ * The extra row is, effectively, an accordion. The content of this accordion is defined by whatever this function returns.
63
+ *
64
+ * @param item the current item.
65
+ * @returns the React Node to render.
66
+ */
67
+ renderAccordion?: (item: T) => React.ReactNode;
68
+ /**
69
+ * What should make the accordions expand or contract? A click on a button in the last column or a click anywhere in the row?
70
+ *
71
+ * Only valid if `renderAccordion` is set.
72
+ *
73
+ * @default 'button'
74
+ */
75
+ accordionTrigger?: 'button' | 'row';
76
+ /**
77
+ * The maximum height for accordion rows.
78
+ *
79
+ * @default '200px'
80
+ */
81
+ accordionMaxHeight?: string;
82
+ }
83
+ export type BaseSmartTableProps<T extends Record<string, any>> = BaseTableProps & ExtraSmartTableProps<T>;
84
+ export type SmartTableProps<T extends Record<string, any>> = Omit<TableProps, 'children'> & ExtraSmartTableProps<T>;
85
+ export declare function SmartTable<T extends Record<string, any>>({ data, keygen, columns, renderAccordion, accordionTrigger, accordionMaxHeight, id, ...props }: SmartTableProps<T>): import("react/jsx-runtime").JSX.Element;
86
+ export {};
87
+ //# sourceMappingURL=SmartTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmartTable.d.ts","sourceRoot":"","sources":["../../src/components/SmartTable.tsx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AM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,cAAc,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAEzG,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAEnH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtD,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,2CAwDnH"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { useMemo } from 'react';
4
+ import { Table, Th, Tr } from './Table.js';
5
+ export function SmartTable({ data, keygen, columns, renderAccordion, accordionTrigger, accordionMaxHeight, id, ...props }) {
6
+ id = useMemo(() => id || `${Math.random()}`, [id]);
7
+ const headers = useMemo(() => columns.map((c) => (_createElement(Th, { ...c.th, key: c.key, onSort: c.onSort, direction: c.direction, tabIndex: c.onSort ? 0 : undefined }, c.label ?? c.key))), [columns]);
8
+ const rows = useMemo(() => data.map((item, index) => {
9
+ const key = keygen ? keygen(item) : index;
10
+ const accordionContent = renderAccordion?.(item);
11
+ const row = (_jsxs(Tr, { accordionTrigger: accordionContent ? accordionTrigger : undefined, children: [columns.map(c => _createElement("td", { ...c.td, key: c.key }, c.render ? c.render(item) : (item[c.key] || ''))), renderAccordion && (_jsx("td", { children: accordionContent && (_jsx("input", { type: "checkbox", "aria-controls": `${id}-${key}`, onKeyDown: e => e.key === 'Enter' && e.target instanceof HTMLElement && e.target.click() })) }))] }, key));
12
+ return renderAccordion ? (_jsxs("tbody", { children: [row, _jsx(Tr, { id: `${id}-${key}`, accordion: true, accordionMaxHeight: accordionMaxHeight, children: _jsx("td", { colSpan: columns.length + 1, children: _jsx("div", { children: accordionContent }) }) })] }, `${key}-group`)) : row;
13
+ }), [columns, data, !!renderAccordion, accordionTrigger]);
14
+ return (_jsxs(Table, { id: id, accordionRows: !!renderAccordion, ...props, children: [_jsx("thead", { children: _jsxs("tr", { children: [headers, renderAccordion && _jsx("th", {})] }) }), renderAccordion ? rows : _jsx("tbody", { children: rows })] }));
15
+ }
16
+ //# sourceMappingURL=SmartTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmartTable.js","sourceRoot":"","sources":["../../src/components/SmartTable.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAoC,KAAK,EAAc,EAAE,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAyFrF,MAAM,UAAU,UAAU,CACxB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,KAAK,EAAsB;IAElH,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAElD,MAAM,OAAO,GAAG,OAAO,CACrB,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACvB,eAAC,EAAE,OAAK,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IACnG,CAAC,CAA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BAAkB,YACtE,aAAI,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,YAAE,wBAAM,gBAAgB,GAAO,GAAK,GAChE,KAJK,GAAG,GAAG,QAAQ,CAKlB,CACT,CAAC,CAAC,CAAC,GAAG,CAAA;IACT,CAAC,CAAC,EACF,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,eAAe,EAAE,gBAAgB,CAAC,CACrD,CAAA;IAED,OAAO,CACL,MAAC,KAAK,IAAC,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC,eAAe,KAAM,KAAK,aACxD,0BACE,yBACG,OAAO,EACP,eAAe,IAAI,cAAS,IAC1B,GACC,EACP,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAAQ,IAAI,GAAS,IACzC,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { HTMLExtension } from '../types.js';
2
+ import { BaseTabsProps } from './Tabs/types.js';
3
+ export interface BaseStepperProps<Key extends string> extends BaseTabsProps<Key> {
4
+ /**
5
+ * Should we show buttons to control the step we are in?
6
+ *
7
+ * Set it to false to not show any buttons, set it to true to show a default set of buttons, set it to an object to customize the buttons.
8
+ *
9
+ * @default true
10
+ */
11
+ buttons?: boolean | {
12
+ /**
13
+ * The text for the previous button.
14
+ */
15
+ previous?: string;
16
+ /**
17
+ * The text for the next button.
18
+ */
19
+ next?: string;
20
+ /**
21
+ * The text for the finish button.
22
+ */
23
+ finish?: string;
24
+ /**
25
+ * The text for the cancel button.
26
+ */
27
+ cancel?: string;
28
+ /**
29
+ * When set, instead of not showing a previous button in the first step, it shows a cancel button. This function is run whenever the
30
+ * cancel button is clicked.
31
+ */
32
+ onCancel?: () => void;
33
+ /**
34
+ * An additional function to run whenever the previous button is clicked. Return false to prevent the default action (going to the
35
+ * previous step).
36
+ */
37
+ onPrevious?: (tab: Key) => void | boolean;
38
+ /**
39
+ * An additional function to run whenever the next button is clicked. Return false to prevent the default action (going to the
40
+ * next step).
41
+ */
42
+ onNext?: (tab: Key) => void | boolean;
43
+ /**
44
+ * When set, instead of not showing a next button in the final step, it shows a finish button. This function is run whenever the
45
+ * finish button is clicked.
46
+ */
47
+ onFinish?: () => void;
48
+ };
49
+ }
50
+ export type StepperProps<Key extends string> = HTMLExtension<'div', BaseStepperProps<Key>, 'children' | 'value' | 'onChange'>;
51
+ export declare function Stepper<Key extends string>({ tabs: initialTabs, controller: ctrl, value, onChange, buttons, className, ...props }: StepperProps<Key>): import("react/jsx-runtime").JSX.Element;
52
+ //# sourceMappingURL=Stepper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../src/components/Stepper.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAKxC,OAAO,EAAE,aAAa,EAAO,MAAM,cAAc,CAAA;AAGjD,MAAM,WAAW,gBAAgB,CAAC,GAAG,SAAS,MAAM,CAAE,SAAQ,aAAa,CAAC,GAAG,CAAC;IAC9E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG;QAClB;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;;WAGG;QACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;QACtB;;;WAGG;QACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC;QAC1C;;;WAGG;QACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC;QACtC;;;WAGG;QACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;KACvB,CAAC;CACH;AAED,MAAM,MAAM,YAAY,CAAC,GAAG,SAAS,MAAM,IAAI,aAAa,CAAC,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC,CAAA;AAQ7H,wBAAgB,OAAO,CAAC,GAAG,SAAS,MAAM,EACxC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAc,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,2CA0DjH"}
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { listToClass } from '@stack-spot/portal-theme';
3
+ import { useTranslate } from '@stack-spot/portal-translate';
4
+ import { useCallback, useEffect, useMemo, useState } from 'react';
5
+ import { Button } from './Button.js';
6
+ import { Column, Row } from './layout.js';
7
+ import { Tabs } from './Tabs/index.js';
8
+ import { TabController } from './Tabs/TabController.js';
9
+ import { findSelectedIndex } from './Tabs/utils.js';
10
+ function getTabsWithDisabled(tabs, value) {
11
+ let index = findSelectedIndex(tabs, value ?? '');
12
+ if (index < 0)
13
+ index = 0;
14
+ return tabs.map((t, i) => ({ ...t, disabled: i > index }));
15
+ }
16
+ export function Stepper({ tabs: initialTabs, controller: ctrl, value, onChange, buttons = true, className, ...props }) {
17
+ const controller = useMemo(() => ctrl ?? new TabController(initialTabs.map(t => t.key), value || initialTabs[0]?.key), []);
18
+ const [tabs, setTabs] = useState(getTabsWithDisabled(initialTabs, value));
19
+ const [selectedIndex, setSelectedIndex] = useState(findSelectedIndex(tabs, controller.getValue()));
20
+ const t = useTranslate(dictionary);
21
+ useEffect(() => controller.onChange((v) => {
22
+ setSelectedIndex(findSelectedIndex(tabs, v));
23
+ }), [tabs]);
24
+ useEffect(() => controller.onChange((value) => {
25
+ setTabs(getTabsWithDisabled(initialTabs, value));
26
+ }), []);
27
+ const onPrevious = useCallback(() => {
28
+ controller.previous();
29
+ if (typeof buttons === 'object')
30
+ buttons.onPrevious?.(controller.getValue());
31
+ }, []);
32
+ const onNext = useCallback(() => {
33
+ controller.next();
34
+ if (typeof buttons === 'object')
35
+ buttons.onNext?.(controller.getValue());
36
+ }, []);
37
+ return buttons ? (_jsxs(Column, { ...props, className: className, gap: "20px", children: [_jsx(Tabs, { tabs: tabs, controller: controller, value: value, onChange: onChange, className: "stepper" }), _jsxs(Row, { justifyContent: (typeof buttons !== 'object' || !buttons.onCancel) && selectedIndex === 0 ? 'end' : 'space-between', children: [selectedIndex === 0 && typeof buttons === 'object' && buttons.onCancel && (_jsx(Button, { onClick: buttons.onCancel, colorScheme: "inverse", appearance: "outlined", children: buttons.cancel || t.cancel })), selectedIndex > 0 && buttons && (_jsx(Button, { onClick: onPrevious, colorScheme: "inverse", appearance: "outlined", children: (typeof buttons === 'object' && buttons.previous) || t.previous })), selectedIndex < tabs.length - 1 && buttons && (_jsx(Button, { onClick: onNext, children: (typeof buttons === 'object' && buttons.next) || t.next })), selectedIndex === tabs.length - 1 && typeof buttons === 'object' && buttons.onFinish && (_jsx(Button, { onClick: buttons.onFinish, children: buttons.finish || t.finish }))] })] })) : _jsx(Tabs, { tabs: tabs, controller: controller, value: value, onChange: onChange, className: listToClass([className, 'stepper']), ...props });
38
+ }
39
+ const dictionary = {
40
+ en: {
41
+ cancel: 'Cancel',
42
+ previous: 'Previous',
43
+ next: 'Next',
44
+ finish: 'Finish',
45
+ },
46
+ pt: {
47
+ cancel: 'Cancelar',
48
+ previous: 'Anterior',
49
+ next: 'Próximo',
50
+ finish: 'Finalizar',
51
+ },
52
+ };
53
+ //# sourceMappingURL=Stepper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stepper.js","sourceRoot":"","sources":["../../src/components/Stepper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AACv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IACP,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,WAAW,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,KAC1C,KAAK,GACT,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;KACjB;IACD,EAAE,EAAE;QACF,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,WAAW;KACpB;CACmB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { HTMLExtension, WithColorScheme } from '../types.js';
2
+ interface Props extends WithColorScheme {
3
+ value?: boolean;
4
+ onChange?: (value: boolean) => void;
5
+ children?: React.ReactNode;
6
+ }
7
+ export type SwitchProps = HTMLExtension<'input', Props, 'type'>;
8
+ export declare const Switch: ({ value, onChange, children, className, style, ...props }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=Switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAGzD,UAAU,KAAM,SAAQ,eAAe;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AAE/D,eAAO,MAAM,MAAM,GAAI,2DAA2D,WAAW,4CAiB5F,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CitricComponent } from './CitricComponent.js';
3
+ export const Switch = ({ value, onChange, children, className, style, ...props }) => {
4
+ const handleChange = onChange ? () => onChange(!value) : undefined;
5
+ return children ? (_jsxs(CitricComponent, { tag: "label", component: "switch-row", style: style, className: className, children: [_jsx("input", { type: "checkbox", checked: value, onChange: handleChange, ...props }), children] })) : _jsx(CitricComponent, { tag: "input", type: "checkbox", component: "switch", checked: value, onChange: handleChange, className: className, style: style, ...props });
6
+ };
7
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAUnD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,EAAe,EAAE,EAAE;IAC/F,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,MAAC,eAAe,IAAC,GAAG,EAAC,OAAO,EAAC,SAAS,EAAC,YAAY,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,aACpF,gBAAO,IAAI,EAAC,UAAU,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,KAAM,KAAK,GAAI,EAC3E,QAAQ,IACO,CACnB,CAAC,CAAC,CAAC,KAAC,eAAe,IAClB,GAAG,EAAC,OAAO,EACX,IAAI,EAAC,UAAU,EACf,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,KACR,KAAK,GACT,CAAA;AACJ,CAAC,CAAA"}